Skip to content

Commit 4735956

Browse files
authored
fix return types of our 64-bit clz/ctz/popcount intrinsics (#4238)
the corresponding LLVM intrinsics' return types are same as their first argument. eg. i64 for llvm.cttz.i64. cf. https://llvm.org/docs/LangRef.html#llvm-cttz-intrinsic this commit changes the return types of our versions of the intrinsics to match llvm versions as our aot compiler, specifically __call_llvm_intrinsic, assumes. strictly speaking, this is a potential AOT ABI change. however, I suppose it isn't a problem for many of 64-bit ABIs out there, where (lower half of) a 64-bit register is used to return a 32-bit value anyway. (for such ABIs, this commit would fix the upper 32-bit value of the register.)
1 parent 5910e5c commit 4735956

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

core/iwasm/aot/aot_intrinsic.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ aot_intrinsic_clz_i32(uint32 type)
194194
return num;
195195
}
196196

197-
uint32
197+
uint64
198198
aot_intrinsic_clz_i64(uint64 type)
199199
{
200200
uint32 num = 0;
@@ -220,7 +220,7 @@ aot_intrinsic_ctz_i32(uint32 type)
220220
return num;
221221
}
222222

223-
uint32
223+
uint64
224224
aot_intrinsic_ctz_i64(uint64 type)
225225
{
226226
uint32 num = 0;
@@ -244,7 +244,7 @@ aot_intrinsic_popcnt_i32(uint32 u)
244244
return ret;
245245
}
246246

247-
uint32
247+
uint64
248248
aot_intrinsic_popcnt_i64(uint64 u)
249249
{
250250
uint32 ret = 0;

core/iwasm/aot/aot_intrinsic.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,19 @@ aot_intrinsic_fmax_f64(float64 a, float64 b);
186186
uint32
187187
aot_intrinsic_clz_i32(uint32 type);
188188

189-
uint32
189+
uint64
190190
aot_intrinsic_clz_i64(uint64 type);
191191

192192
uint32
193193
aot_intrinsic_ctz_i32(uint32 type);
194194

195-
uint32
195+
uint64
196196
aot_intrinsic_ctz_i64(uint64 type);
197197

198198
uint32
199199
aot_intrinsic_popcnt_i32(uint32 u);
200200

201-
uint32
201+
uint64
202202
aot_intrinsic_popcnt_i64(uint64 u);
203203

204204
float32

0 commit comments

Comments
 (0)