Skip to content

Commit 28f1b1c

Browse files
committed
lower_lea: temporary hack
1 parent 18fd19e commit 28f1b1c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/shady/passes/lower_lea.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ typedef struct {
1616
const CompilerConfig* config;
1717
} Context;
1818

19+
// TODO: make this configuration-dependant
20+
static bool is_as_emulated(SHADY_UNUSED Context* ctx, AddressSpace as) {
21+
switch (as) {
22+
case AsPrivate: return true; // TODO have a config option to do this with swizzled global memory
23+
case AsSubgroup: return true;
24+
case AsShared: return true;
25+
case AsGlobal: return true; // TODO have a config option to do this with SSBOs
26+
default: return false;
27+
}
28+
}
29+
1930
static const Node* lower_ptr_arithm(Context* ctx, BodyBuilder* bb, const Type* pointer_type, const Node* base, const Node* offset, size_t n_indices, const Node** indices) {
2031
IrArena* a = ctx->rewriter.dst_arena;
2132
const Type* emulated_ptr_t = int_type(a, (Int) { .width = a->config.memory.ptr_size, .is_signed = false });
@@ -110,7 +121,7 @@ static const Node* process(Context* ctx, const Node* old) {
110121
bool must_lower = false;
111122
// we have to lower generic pointers if we emulate them using ints
112123
must_lower |= ctx->config->lower.emulate_generic_ptrs && old_base_ptr_t->payload.ptr_type.address_space == AsGeneric;
113-
must_lower |= ctx->config->lower.emulate_physical_memory && !old_base_ptr_t->payload.ptr_type.is_reference;
124+
must_lower |= ctx->config->lower.emulate_physical_memory && !old_base_ptr_t->payload.ptr_type.is_reference && is_as_emulated(ctx, old_base_ptr_t->payload.ptr_type.address_space);
114125
if (!must_lower)
115126
break;
116127
BodyBuilder* bb = begin_body(a);

0 commit comments

Comments
 (0)