From fec6595d211e7e3ea616d8335fe5d143a4a7507d Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Fri, 19 Mar 2021 20:35:05 -0400 Subject: feat(gs/achilles): Codegen string literals 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 --- users/glittershark/achilles/src/codegen/llvm.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'users') 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, .. } => { -- cgit 1.4.1