Skip to content

Commit abde200

Browse files
committed
feat(bleach): change function signatures
1 parent adf4a4f commit abde200

12 files changed

Lines changed: 19 additions & 17 deletions

File tree

lib/lifter/lifter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ auto *create_bleach_symtab_lookup_function_decl(Module &m) {
214214
}
215215
auto *generate_function_object(Module &m, MachineFunction &mf) {
216216
auto *ret_type = mf.getFunction().getFunctionType()->getReturnType();
217+
ret_type = Type::getVoidTy(m.getContext());
217218
auto *func_type = FunctionType::get(
218219
ret_type, ArrayRef<Type *>{PointerType::getUnqual(m.getContext())},
219220
/* is var arg */ false);
@@ -693,7 +694,7 @@ static auto generate_return(const MachineInstr &minst,
693694
const Function *func) -> Value * {
694695
// TODO: properly handle return operand
695696
// non-void case
696-
if (minst.getNumOperands() >= 1) {
697+
if (false && minst.getNumOperands() >= 1) {
697698
auto ret = minst.getOperand(0);
698699
assert(ret.isReg());
699700
auto *reg_val =
@@ -1144,6 +1145,7 @@ Module &bleach_module(Module &m, MachineModuleInfo &mmi,
11441145
for (auto &&[oldf, func_info] : funcs)
11451146
generate_function(*oldf, func_info, instrs, mmi, state, reg_stats,
11461147
assume_functions_nop);
1148+
m.print(errs(), nullptr);
11471149
if (finfo) {
11481150
for (auto *func :
11491151
translated | views::filter([](auto *f) { return !f->empty(); }))

test/integration/indbr.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ main:
2828
addi a0, a0, -5
2929
ret
3030

31-
# CHECK: define i64 @count_to_5
31+
# CHECK: define void @count_to_5
3232
# CHECK-NEXT: call void @bleach_symtab_add(i64 0, ptr @count_to_5)
3333
# CHECK: [[FUNCADDR:%[0-9]+]] = call ptr @bleach_symtab_lookup
34-
# CHECK: musttail call i64 [[FUNCADDR]]
34+
# CHECK: musttail call void [[FUNCADDR]]
3535

test/tools/llvm-bleach/arith-sum/main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
// generated header
66
#include <state.h>
77

8-
extern double arith_seq_sum(struct register_state *st);
9-
108
static struct register_state regs = {};
119

1210
double uitod(int64_t n) {

test/tools/llvm-bleach/fact/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ static struct register_state regs = {};
77
static long long lifted_factorial(long long n) {
88
// According to RISC-V calling convention X10 is the first argument
99
regs.GPR[10] = n;
10-
return fact(&regs);
10+
fact(&regs);
11+
return regs.GPR[10];
1112
}
1213

1314
void test(long long n) {

test/tools/llvm-bleach/fibonacci/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ static struct register_state regs = {};
77
static long long lifted_fibonacci(long long n) {
88
// According to RISC-V calling convention X10 is the first argument
99
regs.GPR[10] = n;
10-
return fibonacci(&regs);
10+
fibonacci(&regs);
11+
return regs.GPR[10];
1112
}
1213

1314
void test(long long n) {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# RUN: %bin/llvm-bleach %S/inputs/logical-branches.mir \
22
# RUN: --instructions=%S/inputs/logical.yaml -noinline-instr | FileCheck %s
33

4-
# CHECK: define i64 @foo(ptr %0) {
4+
# CHECK: define void @foo(ptr %0) {
55
# CHECK-NEXT: %GPR = getelementptr %register_state, ptr %0, i32 0, i32 0
66
# CHECK: br label %[[BLOCK1:[0-9]+]]
77
# CHECK: [[BLOCK1]]:
8-
# CHECK: ret i64 %[[RET:[0-9]+]]
8+
# CHECK: ret void
99
# CHECK-NEXT: }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# RUN: %bin/llvm-bleach %S/inputs/logical-cond-branches-no-blocks.mir \
22
# RUN: --instructions=%S/inputs/logical.yaml -noinline-instr | FileCheck %s
33

4-
# CHECK: define i64 @foo(ptr %0) {
4+
# CHECK: define void @foo(ptr %0) {
55
# CHECK-NEXT: %GPR = getelementptr %register_state, ptr %0, i32 0, i32 0
66
# CHECK: br label %[[BLOCK1:[0-9]+]]
77
# CHECK: [[BLOCK1]]:
88
# CHECK: br i1 %{{.*}}, label %[[BLOCK1]], label %[[BLOCK2:[0-9]+]]
99
# CHECK: [[BLOCK2]]:
10-
# CHECK: ret i64
10+
# CHECK: ret void
1111
# CHECK: }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# RUN: %bin/llvm-bleach %S/inputs/logical-cond-branches.mir \
22
# RUN: --instructions=%S/inputs/logical.yaml -noinline-instr | FileCheck %s
33

4-
# CHECK: define i64 @foo(ptr %0) {
4+
# CHECK: define void @foo(ptr %0) {
55
# CHECK-NEXT: %GPR = getelementptr %register_state, ptr %0, i32 0, i32 0
66
# CHECK: br label %[[BLOCK1:[0-9]+]]
77
# CHECK: [[BLOCK1]]:
88
# CHECK: br i1 %{{.*}}, label %[[BLOCK1]], label %[[BLOCK2:[0-9]+]]
99
# CHECK: [[BLOCK2]]:
10-
# CHECK: ret i64
10+
# CHECK: ret void
1111
# CHECK: }

test/tools/llvm-bleach/ir-logical.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RUN: %bin/llvm-bleach %S/inputs/logical.mir \
22
# RUN: --instructions=%S/inputs/logical.yaml -noinline-instr | FileCheck %s
33

4-
# CHECK: define i64 @foo(ptr %0) {
4+
# CHECK: define void @foo(ptr %0) {
55
# CHECK-NEXT: %GPR = getelementptr %register_state, ptr %0, i32 0, i32 0
66
# CHECK: [[X10ADDR:%[0-9]+]] = getelementptr inbounds [32 x i64], ptr %GPR, i32 0, i32 10
77
# CHECK-NEXT: [[X10:%[0-9]+]] = load i64, ptr [[X10ADDR]], align 8

test/tools/llvm-bleach/main.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# RUN: %bin/llvm-bleach %S/inputs/main-ret-zero.mir \
22
# RUN: --instructions=%S/inputs/logical.yaml | FileCheck %s
33

4-
# CHECK: define i32 @bleached_main(ptr %0)
4+
# CHECK: define void @bleached_main(ptr %0)

0 commit comments

Comments
 (0)