Skip to content

Commit 65bc29b

Browse files
authored
Fix handling of complex floats (#299)
* Init expr * Support struct-abi=0 for complex nums
1 parent 1621eda commit 65bc29b

File tree

7 files changed

+523
-64
lines changed

7 files changed

+523
-64
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# vim swap files
1919
.*.sw?
2020
.sw?
21+
# emacs swap files
22+
\#*\#
2123
#OS X specific files.
2224
.DS_store
2325
# Tests
@@ -27,6 +29,8 @@
2729
*.inc
2830
*.cmake
2931
*.a
32+
# gdb local history files
33+
.gdb_history
3034
##
3135

3236
# Ignore the user specified CMake presets in subproject directories.

tools/cgeist/Lib/CGCall.cc

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,18 @@ ValueCategory MLIRScanner::CallHelper(
252252
auto l0 = Visit(CU->getConfig()->getArg(0));
253253
assert(l0.isReference);
254254
mlir::Value blocks[3];
255+
mlir::Value val = l0.val;
256+
if (auto MT = val.getType().dyn_cast<MemRefType>()) {
257+
if (MT.getElementType().isa<LLVM::LLVMStructType>() &&
258+
MT.getShape().size() == 1) {
259+
val = builder.create<polygeist::Memref2PointerOp>(
260+
loc,
261+
LLVM::LLVMPointerType::get(MT.getElementType(),
262+
MT.getMemorySpaceAsInt()),
263+
val);
264+
}
265+
}
255266
for (int i = 0; i < 3; i++) {
256-
mlir::Value val = l0.val;
257267
if (auto MT = val.getType().dyn_cast<MemRefType>()) {
258268
mlir::Value idx[] = {getConstantIndex(0), getConstantIndex(i)};
259269
assert(MT.getShape().size() == 2);
@@ -278,8 +288,18 @@ ValueCategory MLIRScanner::CallHelper(
278288
auto t0 = Visit(CU->getConfig()->getArg(1));
279289
assert(t0.isReference);
280290
mlir::Value threads[3];
291+
val = t0.val;
292+
if (auto MT = val.getType().dyn_cast<MemRefType>()) {
293+
if (MT.getElementType().isa<LLVM::LLVMStructType>() &&
294+
MT.getShape().size() == 1) {
295+
val = builder.create<polygeist::Memref2PointerOp>(
296+
loc,
297+
LLVM::LLVMPointerType::get(MT.getElementType(),
298+
MT.getMemorySpaceAsInt()),
299+
val);
300+
}
301+
}
281302
for (int i = 0; i < 3; i++) {
282-
mlir::Value val = t0.val;
283303
if (auto MT = val.getType().dyn_cast<MemRefType>()) {
284304
mlir::Value idx[] = {getConstantIndex(0), getConstantIndex(i)};
285305
assert(MT.getShape().size() == 2);

0 commit comments

Comments
 (0)