diff options
author | Griffin Smith <grfn@gws.fyi> | 2021-03-20T00·35-0400 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2021-03-20T20·20+0000 |
commit | fec6595d211e7e3ea616d8335fe5d143a4a7507d (patch) | |
tree | b26dfd80537c4eba059d3b471b42f079b3133625 /users/glittershark/achilles/src/codegen/llvm.rs | |
parent | b1c4b84dbac9073e5f4b1dd7c5e0b7f549a32200 (diff) |
feat(gs/achilles): Codegen string literals r/2292
Codegen string literals to LLVM as (for now) global C string pointers Change-Id: I6dcd7fa25a7806a2f708a8e9275c9a01174fd0cf Reviewed-on: https://cl.tvl.fyi/c/depot/+/2613 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to 'users/glittershark/achilles/src/codegen/llvm.rs')
-rw-r--r-- | users/glittershark/achilles/src/codegen/llvm.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/users/glittershark/achilles/src/codegen/llvm.rs b/users/glittershark/achilles/src/codegen/llvm.rs index ee087845b640..9b580d3c4536 100644 --- a/users/glittershark/achilles/src/codegen/llvm.rs +++ b/users/glittershark/achilles/src/codegen/llvm.rs @@ -92,7 +92,11 @@ impl<'ctx, 'ast> Codegen<'ctx, 'ast> { Literal::Bool(b) => Ok(AnyValueEnum::IntValue( ty.const_int(if *b { 1 } else { 0 }, false), )), - Literal::String(_) => todo!(), + Literal::String(s) => Ok(self + .builder + .build_global_string_ptr(s, "s") + .as_pointer_value() + .into()), } } Expr::UnaryOp { op, rhs, .. } => { |