Skip to content

Commit 84b664a

Browse files
authored
[mono][llvm] Refactor code to make it easier to support LLVM 13.x in … (#67692)
* [mono][llvm] Refactor code to make it easier to support LLVM 13.x in the future * Remove some c++ functions which can be implemented using the C API. * Use call_intrins in more places. * Use the const_int32 ()/const_int64 () helper functions in more places. * Use opaque pointer type APIs. LLVM is transitioning to using opaque pointer types, i.e. pointer types with no element type. Transition the LLVM backend to do the same. * Add an 'Address' structure which represents a pointer value and its element type, use it in places where the element type of a pointer is not locally available, like for globals. * Use LLVMBuildCall2/BuildInvoke2 functions where possible. * Fix the build.
1 parent 5385962 commit 84b664a

File tree

3 files changed

+423
-433
lines changed

3 files changed

+423
-433
lines changed

src/mono/mono/mini/mini-llvm-cpp.cpp

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,6 @@ mono_llvm_build_alloca (LLVMBuilderRef builder, LLVMTypeRef Ty, LLVMValueRef Arr
104104
return wrap (ins);
105105
}
106106

107-
LLVMValueRef
108-
mono_llvm_build_load (LLVMBuilderRef builder, LLVMValueRef PointerVal,
109-
const char *Name, gboolean is_volatile)
110-
{
111-
LoadInst *ins = unwrap(builder)->CreateLoad(unwrap(PointerVal), is_volatile, Name);
112-
113-
return wrap(ins);
114-
}
115-
116107
LLVMValueRef
117108
mono_llvm_build_atomic_load (LLVMBuilderRef builder, LLVMValueRef PointerVal,
118109
const char *Name, gboolean is_volatile, int alignment, BarrierKind barrier)
@@ -150,10 +141,25 @@ mono_llvm_build_aligned_load (LLVMBuilderRef builder, LLVMValueRef PointerVal,
150141
}
151142

152143
LLVMValueRef
153-
mono_llvm_build_store (LLVMBuilderRef builder, LLVMValueRef Val, LLVMValueRef PointerVal,
154-
gboolean is_volatile, BarrierKind barrier)
144+
mono_llvm_build_aligned_store (LLVMBuilderRef builder, LLVMValueRef Val, LLVMValueRef PointerVal,
145+
gboolean is_volatile, int alignment)
146+
{
147+
StoreInst *ins;
148+
149+
ins = unwrap(builder)->CreateStore(unwrap(Val), unwrap(PointerVal), is_volatile);
150+
ins->setAlignment (to_align (alignment));
151+
152+
return wrap (ins);
153+
}
154+
155+
LLVMValueRef
156+
mono_llvm_build_atomic_store (LLVMBuilderRef builder, LLVMValueRef Val, LLVMValueRef PointerVal,
157+
BarrierKind barrier, int alignment)
155158
{
156-
StoreInst *ins = unwrap(builder)->CreateStore(unwrap(Val), unwrap(PointerVal), is_volatile);
159+
StoreInst *ins;
160+
161+
ins = unwrap(builder)->CreateStore(unwrap(Val), unwrap(PointerVal), false);
162+
ins->setAlignment (to_align (alignment));
157163

158164
switch (barrier) {
159165
case LLVM_BARRIER_NONE:
@@ -169,18 +175,6 @@ mono_llvm_build_store (LLVMBuilderRef builder, LLVMValueRef Val, LLVMValueRef Po
169175
break;
170176
}
171177

172-
return wrap(ins);
173-
}
174-
175-
LLVMValueRef
176-
mono_llvm_build_aligned_store (LLVMBuilderRef builder, LLVMValueRef Val, LLVMValueRef PointerVal,
177-
gboolean is_volatile, int alignment)
178-
{
179-
StoreInst *ins;
180-
181-
ins = unwrap(builder)->CreateStore(unwrap(Val), unwrap(PointerVal), is_volatile);
182-
ins->setAlignment (to_align (alignment));
183-
184178
return wrap (ins);
185179
}
186180

src/mono/mono/mini/mini-llvm-cpp.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ mono_llvm_build_alloca (LLVMBuilderRef builder, LLVMTypeRef Ty,
6767
LLVMValueRef ArraySize,
6868
int alignment, const char *Name);
6969

70-
LLVMValueRef
71-
mono_llvm_build_load (LLVMBuilderRef builder, LLVMValueRef PointerVal,
72-
const char *Name, gboolean is_volatile);
73-
7470
LLVMValueRef
7571
mono_llvm_build_atomic_load (LLVMBuilderRef builder, LLVMValueRef PointerVal,
7672
const char *Name, gboolean is_volatile, int alignment, BarrierKind barrier);
@@ -79,14 +75,14 @@ LLVMValueRef
7975
mono_llvm_build_aligned_load (LLVMBuilderRef builder, LLVMValueRef PointerVal,
8076
const char *Name, gboolean is_volatile, int alignment);
8177

82-
LLVMValueRef
83-
mono_llvm_build_store (LLVMBuilderRef builder, LLVMValueRef Val, LLVMValueRef PointerVal,
84-
gboolean is_volatile, BarrierKind kind);
85-
8678
LLVMValueRef
8779
mono_llvm_build_aligned_store (LLVMBuilderRef builder, LLVMValueRef Val, LLVMValueRef PointerVal,
8880
gboolean is_volatile, int alignment);
8981

82+
LLVMValueRef
83+
mono_llvm_build_atomic_store (LLVMBuilderRef builder, LLVMValueRef Val, LLVMValueRef PointerVal,
84+
BarrierKind barrier, int alignment);
85+
9086
LLVMValueRef
9187
mono_llvm_build_atomic_rmw (LLVMBuilderRef builder, AtomicRMWOp op, LLVMValueRef ptr, LLVMValueRef val);
9288

0 commit comments

Comments
 (0)