aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2021-05-15 03:27:59 +0200
committerRobin Voetter <robin@voetter.nl>2021-05-16 14:13:23 +0200
commitda0cc732ea899d2284200faf54c3c12e8c798b7f (patch)
tree186620f16603ad01ad74b1fff0928054e0c332cf /src/codegen/spirv.zig
parent074cb9f1daff0f9d8c3bc5736b8990aa53eb8226 (diff)
downloadzig-da0cc732ea899d2284200faf54c3c12e8c798b7f.tar.gz
zig-da0cc732ea899d2284200faf54c3c12e8c798b7f.zip
SPIR-V: Function parameter generation
Diffstat (limited to 'src/codegen/spirv.zig')
-rw-r--r--src/codegen/spirv.zig13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig
index db4ddbd657..a6b8216774 100644
--- a/src/codegen/spirv.zig
+++ b/src/codegen/spirv.zig
@@ -57,6 +57,7 @@ pub const DeclGen = struct {
module: *Module,
spv: *SPIRVModule,
+ args: std.ArrayList(u32),
types: TypeMap,
decl: *Decl,
@@ -213,7 +214,17 @@ pub const DeclGen = struct {
prototype_id,
});
- // TODO: Parameters
+ const params = tv.ty.fnParamLen();
+ var i: usize = 0;
+
+ try self.args.ensureCapacity(params);
+ while (i < params) : (i += 1) {
+ const param_type_id = self.types.get(tv.ty.fnParamType(i)).?;
+ const arg_result_id = self.spv.allocResultId();
+ try writeInstruction(&self.spv.fn_decls, .OpFunctionParameter, &[_]u32{ param_type_id, arg_result_id });
+ self.args.appendAssumeCapacity(arg_result_id);
+ }
+
// TODO: Body
try writeInstruction(&self.spv.fn_decls, .OpFunctionEnd, &[_]u32{});