Skip to content

Commit b1f59cd

Browse files
committed
prefix some things in check.c
1 parent f7e7850 commit b1f59cd

File tree

17 files changed

+62
-61
lines changed

17 files changed

+62
-61
lines changed

include/shady/ir/base.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,5 @@ String string(IrArena*, const char*);
5050
// see also: format_string in util.h
5151
String shd_fmt_string_irarena(IrArena* arena, const char* str, ...);
5252
String unique_name(IrArena*, const char* base_name);
53-
String name_type_safe(IrArena*, const Type*);
5453

5554
#endif

include/shady/ir/type.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ static inline const Node* unit_type(IrArena* arena) {
1313

1414
Type* nominal_type(Module*, Nodes annotations, String name);
1515

16-
const Type* get_actual_mask_type(IrArena* arena);
16+
const Type* shd_get_actual_mask_type(IrArena* arena);
1717

1818
String get_address_space_name(AddressSpace);
1919
/// Returns false iff pointers in that address space can contain different data at the same address
2020
/// (amongst threads in the same subgroup)
21-
bool is_addr_space_uniform(IrArena*, AddressSpace);
21+
bool shd_is_addr_space_uniform(IrArena*, AddressSpace);
22+
23+
String shd_get_type_name(IrArena* arena, const Type* t);
2224

2325
/// Is this a type that a value in the language can have ?
2426
bool is_value_type(const Type*);

src/backend/c/emit_c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void c_emit_global_variable_definition(Emitter* emitter, AddressSpace as, String
221221

222222
// ISPC wants uniform/varying annotations
223223
if (emitter->config.dialect == CDialect_ISPC) {
224-
bool uniform = is_addr_space_uniform(emitter->arena, as);
224+
bool uniform = shd_is_addr_space_uniform(emitter->arena, as);
225225
if (uniform)
226226
name = shd_format_string_arena(emitter->arena->arena, "uniform %s", name);
227227
else

src/backend/c/emit_c_value.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static CTerm c_emit_value_(Emitter* emitter, FnEmitter* fn, Printer* p, const No
217217
c_emit_decl(emitter, decl);
218218

219219
if (emitter->config.dialect == CDialect_ISPC && decl->tag == GlobalVariable_TAG) {
220-
if (!is_addr_space_uniform(emitter->arena, decl->payload.global_variable.address_space) && !shd_is_decl_builtin(
220+
if (!shd_is_addr_space_uniform(emitter->arena, decl->payload.global_variable.address_space) && !shd_is_decl_builtin(
221221
decl)) {
222222
assert(fn && "ISPC backend cannot statically refer to a varying variable");
223223
return ispc_varying_ptr_helper(emitter, fn->instruction_printers[0], decl->type, *lookup_existing_term(emitter, NULL, decl));
@@ -933,7 +933,7 @@ static CTerm emit_instruction(Emitter* emitter, FnEmitter* fn, Printer* p, const
933933
CAddr dereferenced = deref_term(emitter, c_emit_value(emitter, fn, payload.ptr));
934934
CValue cvalue = to_cvalue(emitter, c_emit_value(emitter, fn, payload.value));
935935
// ISPC lets you broadcast to a uniform address space iff the address is non-uniform, otherwise we need to do this
936-
if (emitter->config.dialect == CDialect_ISPC && addr_uniform && is_addr_space_uniform(a, addr_type->payload.ptr_type.address_space) && !value_uniform)
936+
if (emitter->config.dialect == CDialect_ISPC && addr_uniform && shd_is_addr_space_uniform(a, addr_type->payload.ptr_type.address_space) && !value_uniform)
937937
cvalue = shd_format_string_arena(emitter->arena->arena, "extract(%s, count_trailing_zeros(lanemask()))", cvalue);
938938

939939
shd_print(p, "\n%s = %s;", dereferenced, cvalue);
@@ -987,7 +987,7 @@ static bool can_appear_at_top_level(Emitter* emitter, const Node* node) {
987987
if (node->tag == RefDecl_TAG) {
988988
const Node* decl = node->payload.ref_decl.decl;
989989
if (decl->tag == GlobalVariable_TAG)
990-
if (!is_addr_space_uniform(emitter->arena, decl->payload.global_variable.address_space) && !shd_is_decl_builtin(
990+
if (!shd_is_addr_space_uniform(emitter->arena, decl->payload.global_variable.address_space) && !shd_is_decl_builtin(
991991
decl))
992992
//if (is_value(node) && !is_qualified_type_uniform(node->type))
993993
return false;

src/backend/spirv/emit_spv_value.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ static SpvId emit_ext_instr(Emitter* emitter, FnBuilder* fn_builder, BBBuilder b
295295
assert(instr.operands.count == 2);
296296
// SpvId scope_subgroup = spv_emit_value(emitter, fn_builder, int32_literal(emitter->arena, SpvScopeSubgroup));
297297
// ad-hoc extension for my sanity
298-
if (get_unqualified_type(instr.result_t) == get_actual_mask_type(emitter->arena)) {
298+
if (get_unqualified_type(instr.result_t) == shd_get_actual_mask_type(emitter->arena)) {
299299
const Type* i32x4 = pack_type(emitter->arena, (PackType) { .width = 4, .element_type = shd_uint32_type(emitter->arena) });
300300
SpvId raw_result = spvb_group_ballot(bb_builder, spv_emit_type(emitter, i32x4), spv_emit_value(emitter, fn_builder, instr.operands.nodes[1]), spv_emit_value(emitter, fn_builder, shd_first(instr.operands)));
301301
// TODO: why are we doing this in SPIR-V and not the IR ?

src/frontend/slim/infer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static const Node* infer_value(Context* ctx, const Node* node, const Type* expec
170170
bool expect_uniform = false;
171171
if (expected_type) {
172172
expect_uniform = deconstruct_qualified_type(&expected_type);
173-
assert(is_subtype(expected_type, type));
173+
assert(shd_is_subtype(expected_type, type));
174174
}
175175
return infer(ctx, node->payload.constrained.value, shd_as_qualified_type(type, expect_uniform));
176176
}
@@ -237,7 +237,7 @@ static const Node* infer_value(Context* ctx, const Node* node, const Type* expec
237237
const Node* elem_type = infer(ctx, node->payload.composite.type, NULL);
238238
bool uniform = false;
239239
if (elem_type && expected_type) {
240-
assert(is_subtype(get_unqualified_type(expected_type), elem_type));
240+
assert(shd_is_subtype(get_unqualified_type(expected_type), elem_type));
241241
} else if (expected_type) {
242242
uniform = deconstruct_qualified_type(&elem_type);
243243
elem_type = expected_type;
@@ -266,7 +266,7 @@ static const Node* infer_value(Context* ctx, const Node* node, const Type* expec
266266
assert(composite_t);
267267
bool uniform = false;
268268
if (composite_t && expected_type) {
269-
assert(is_subtype(get_unqualified_type(expected_type), composite_t));
269+
assert(shd_is_subtype(get_unqualified_type(expected_type), composite_t));
270270
} else if (expected_type) {
271271
uniform = deconstruct_qualified_type(&composite_t);
272272
composite_t = expected_type;
@@ -300,7 +300,7 @@ static const Node* infer_case(Context* ctx, const Node* node, Nodes inferred_arg
300300
// and do not use the provided param type if it is an untyped ptr
301301
if (!param_type || param_type->tag != PtrType_TAG || param_type->payload.ptr_type.pointed_type)
302302
param_type = inferred_arg_type.nodes[i];
303-
assert(is_subtype(param_type, inferred_arg_type.nodes[i]));
303+
assert(shd_is_subtype(param_type, inferred_arg_type.nodes[i]));
304304
nparams[i] = param(a, param_type, old_param->name);
305305
shd_register_processed(&body_context.rewriter, node->payload.basic_block.params.nodes[i], nparams[i]);
306306
}

src/shady/analysis/verify.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static void verify_nominal_node(const Node* fn, const Node* n) {
7979
break;
8080
}
8181
case BasicBlock_TAG: {
82-
assert(is_subtype(noret_type(n->arena), n->payload.basic_block.body->type));
82+
assert(shd_is_subtype(noret_type(n->arena), n->payload.basic_block.body->type));
8383
break;
8484
}
8585
case NominalType_TAG: {
@@ -91,7 +91,7 @@ static void verify_nominal_node(const Node* fn, const Node* n) {
9191
const Type* t = n->payload.constant.value->type;
9292
bool u = deconstruct_qualified_type(&t);
9393
assert(u);
94-
assert(is_subtype(n->payload.constant.type_hint, t));
94+
assert(shd_is_subtype(n->payload.constant.type_hint, t));
9595
}
9696
break;
9797
}
@@ -100,7 +100,7 @@ static void verify_nominal_node(const Node* fn, const Node* n) {
100100
const Type* t = n->payload.global_variable.init->type;
101101
bool u = deconstruct_qualified_type(&t);
102102
assert(u);
103-
assert(is_subtype(n->payload.global_variable.type, t));
103+
assert(shd_is_subtype(n->payload.global_variable.type, t));
104104
}
105105
break;
106106
}

0 commit comments

Comments
 (0)