aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-12-02 20:59:08 +0000
committergingerBill <bill@gingerbill.org>2018-12-02 20:59:08 +0000
commit304c7594cd2d904072917bb79d0aa340090d8296 (patch)
tree2e5e06962f8d54c72d8b29026306bebb861eaa0e /src
parentd02b0508508dd92e6cb72bd610f33ae37a999ede (diff)
Ignore `ir_emit_byte_swap` for constant values
Diffstat (limited to 'src')
-rw-r--r--src/checker.cpp16
-rw-r--r--src/ir.cpp3
2 files changed, 17 insertions, 2 deletions
diff --git a/src/checker.cpp b/src/checker.cpp
index 75ff5ea65..44a76db67 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -1812,11 +1812,23 @@ void init_core_source_code_location(Checker *c) {
void init_core_map_type(Checker *c) {
if (t_map_key == nullptr) {
- t_map_key = find_core_type(c, str_lit("Map_Key"));
+ Entity *e = find_core_entity(c, str_lit("Map_Key"));
+ if (e->state == EntityState_Unresolved) {
+ auto ctx = c->init_ctx;
+ check_entity_decl(&ctx, e, nullptr, nullptr);
+ }
+ t_map_key = e->type;
+ GB_ASSERT(t_map_key != nullptr);
}
if (t_map_header == nullptr) {
- t_map_header = find_core_type(c, str_lit("Map_Header"));
+ Entity *e = find_core_entity(c, str_lit("Map_Header"));
+ if (e->state == EntityState_Unresolved) {
+ auto ctx = c->init_ctx;
+ check_entity_decl(&ctx, e, nullptr, nullptr);
+ }
+ t_map_header = e->type;
+ GB_ASSERT(t_map_header != nullptr);
}
}
diff --git a/src/ir.cpp b/src/ir.cpp
index bf595251e..ea7719af2 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -4372,6 +4372,9 @@ irValue *ir_emit_uintptr_to_ptr(irProcedure *proc, irValue *value, Type *t) {
irValue *ir_emit_byte_swap(irProcedure *proc, irValue *value, Type *t) {
Type *vt = core_type(ir_type(value));
+ if (is_type_untyped(vt)) {
+ return value;
+ }
GB_ASSERT(type_size_of(vt) == type_size_of(t));
return ir_emit(proc, ir_instr_conv(proc, irConv_byteswap, value, vt, t));
}