@@ -303,6 +303,30 @@ static void pseudo_name(pseudo_t pseudo, char *buf)
}
}
+static LLVMValueRef val_to_value(struct function *fn, unsigned long long val, struct symbol *ctype)
+{
+ LLVMTypeRef dtype;
+ LLVMTypeRef itype;
+ LLVMValueRef result;
+
+ assert(ctype);
+ dtype = symbol_type(fn->module, ctype);
+ switch (LLVMGetTypeKind(dtype)) {
+ case LLVMPointerTypeKind:
+ itype = LLVMIntType(bits_in_pointer);
+ result = LLVMConstInt(itype, val, 1);
+ result = LLVMConstIntToPtr(result, dtype);
+ break;
+ case LLVMIntegerTypeKind:
+ result = LLVMConstInt(dtype, val, 1);
+ break;
+ default:
+ assert(0);
+ }
+
+ return result;
+}
+
static LLVMValueRef pseudo_to_value(struct function *fn, struct instruction *insn, pseudo_t pseudo)
{
LLVMValueRef result = NULL;
This needs to take in account the fact that the value can have a non-integer type, for example it can be an address constant. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- sparse-llvm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)