Skip to content

Commit 834b687

Browse files
committed
temp workaround for failure to pass ulonglong successfully
1 parent 938b23e commit 834b687

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

src/comp/lib/llvm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ native mod llvm {
865865
fn LLVMRustParseBitcode(MemBuf: MemoryBufferRef) -> ModuleRef;
866866

867867
/** FiXME: Hacky adaptor for lack of ULongLong in FFI: */
868-
fn LLVMRustConstSmallInt(IntTy: TypeRef, N: uint, SignExtend: Bool) ->
868+
fn LLVMRustConstInt(IntTy: TypeRef, N_hi: uint, N_lo: uint, SignExtend: Bool) ->
869869
ValueRef;
870870

871871
fn LLVMRustAddPrintModulePass(PM: PassManagerRef, M: ModuleRef,

src/comp/middle/trans_common.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,9 @@ fn T_opaque_chan_ptr() -> TypeRef { ret T_ptr(T_i8()); }
725725
fn C_null(t: TypeRef) -> ValueRef { ret llvm::LLVMConstNull(t); }
726726

727727
fn C_integral(t: TypeRef, u: u64, sign_extend: Bool) -> ValueRef {
728-
ret llvm::LLVMConstInt(t, u, sign_extend);
728+
let u_hi = (u >> 32u64) as uint;
729+
let u_lo = u as uint;
730+
ret llvm::LLVMRustConstInt(t, u_hi, u_lo, sign_extend);
729731
}
730732

731733
fn C_float(cx: @crate_ctxt, s: str) -> ValueRef {

src/rustllvm/RustWrapper.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ extern "C" LLVMValueRef LLVMRustConstSmallInt(LLVMTypeRef IntTy, unsigned N,
126126
return LLVMConstInt(IntTy, (unsigned long long)N, SignExtend);
127127
}
128128

129+
extern "C" LLVMValueRef LLVMRustConstInt(LLVMTypeRef IntTy,
130+
unsigned N_hi,
131+
unsigned N_lo,
132+
LLVMBool SignExtend) {
133+
unsigned long long N = N_hi;
134+
N <<= 32;
135+
N |= N_lo;
136+
return LLVMConstInt(IntTy, N, SignExtend);
137+
}
138+
129139
extern bool llvm::TimePassesIsEnabled;
130140
extern "C" void LLVMRustEnableTimePasses() {
131141
TimePassesIsEnabled = true;

src/rustllvm/rustllvm.def.in

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ LLVMRustWriteOutputFile
44
LLVMRustGetLastError
55
LLVMRustGetHostTriple
66
LLVMRustConstSmallInt
7+
LLVMRustConstInt
78
LLVMRustParseBitcode
89
LLVMRustPrintPassTimings
910
LLVMRustEnableSegmentedStacks

0 commit comments

Comments
 (0)