-
Notifications
You must be signed in to change notification settings - Fork 2
Array compound generation first pass #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rewrite
Are you sure you want to change the base?
Conversation
src/llvm.cpp
Outdated
@@ -1732,16 +1749,26 @@ void emit_decl_var(IRContext *self, Decl *decl) { | |||
return; | |||
} | |||
} | |||
Type *type = llvm_type(self, sym->type); | |||
|
|||
Type *type = llvm_type(self, sym->type, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like I need the true
here for global variables but I'm not exactly sure if I need it for all cases. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense for array's, a Global Variable needs the raw type so it know's how much space to reserve, this actually will cause an error for functions though, llvm_type
will return a FunctionType for functions, this will cause an assert in LLVM when it attempts to work out a size for the global.
I guess maybe we need llvm_type
's hide behind pointer to be a mask maybe? Something like llvm_type(self, sym->type, ARRAY | STRUCT)
and in emit_expr_func
we would have llvm_type(self, type, FUNCTION)
I'm so sorry about the whitespace... Looks like Xcode is mixing tabs and spaces... Will fix later |
@@ -1856,7 +1885,7 @@ void emit_decl_val(IRContext *self, Decl *decl) { | |||
arrpush(self->symbols, sym); | |||
Value *value = emit_expr(self, decl->dval.val).val; | |||
arrpop(self->symbols); | |||
if (isa<Function>(value)) { | |||
if (isa<Function>(value) || isa<StructType>((Type *)value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is bad
src/llvm.cpp
Outdated
@@ -1732,16 +1749,26 @@ void emit_decl_var(IRContext *self, Decl *decl) { | |||
return; | |||
} | |||
} | |||
Type *type = llvm_type(self, sym->type); | |||
|
|||
Type *type = llvm_type(self, sym->type, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense for array's, a Global Variable needs the raw type so it know's how much space to reserve, this actually will cause an error for functions though, llvm_type
will return a FunctionType for functions, this will cause an assert in LLVM when it attempts to work out a size for the global.
I guess maybe we need llvm_type
's hide behind pointer to be a mask maybe? Something like llvm_type(self, sym->type, ARRAY | STRUCT)
and in emit_expr_func
we would have llvm_type(self, type, FUNCTION)
I did a first pass but still would like to clean up a little. Please feel free to nitpick this