Skip to content

Commit

Permalink
Try to fix types for LLVMBuildLoad2 calls
Browse files Browse the repository at this point in the history
  • Loading branch information
fischeti committed Sep 2, 2024
1 parent 3ba34fe commit 862432b
Showing 1 changed file with 56 additions and 62 deletions.
118 changes: 56 additions & 62 deletions src/tran.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ impl<'a> InstructionTranslator<'a> {
}

// Update the instret counter.
let instret = LLVMBuildLoad2(self.builder, LLVMInt32Type(), self.instret_ptr(), NONAME);
let instret = LLVMBuildLoad2(self.builder, LLVMInt64Type(), self.instret_ptr(), NONAME);
let instret = LLVMBuildAdd(
self.builder,
instret,
Expand Down Expand Up @@ -1865,7 +1865,7 @@ impl<'a> InstructionTranslator<'a> {
let ptr = self.freg_ptr(rs);
let rs = LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt64Type(),
ptr,
format!("f{}\0", rs).as_ptr() as *const _,
);
Expand Down Expand Up @@ -3330,7 +3330,7 @@ impl<'a> InstructionTranslator<'a> {
LLVMBuildStore(self.builder, rs1, ptr);
self.trace_access(
TraceAccess::WriteF32Reg(data.rd as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64ype(), raw_ptr, NONAME),

Check failure on line 3333 in src/tran.rs

View workflow job for this annotation

GitHub Actions / Banshee (1.67.0)

cannot find function, tuple struct or tuple variant `LLVMInt64ype` in this scope
);
return Ok(());
}
Expand Down Expand Up @@ -3376,7 +3376,7 @@ impl<'a> InstructionTranslator<'a> {
LLVMBuildStore(self.builder, rs1, ptr);
self.trace_access(
TraceAccess::WriteFReg(data.rd as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);
return Ok(());
}
Expand Down Expand Up @@ -6225,13 +6225,13 @@ impl<'a> InstructionTranslator<'a> {
let cycle = match access {
TraceAccess::ReadReg(i) => LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt64Type(),
self.reg_cycle_ptr(i as u32),
format!("x{}\0", i).as_ptr() as *const _,
),
TraceAccess::ReadFReg(i) => LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt64Type(),
self.freg_cycle_ptr(i as u32),
format!("f{}\0", i).as_ptr() as *const _,
),
Expand All @@ -6242,7 +6242,7 @@ impl<'a> InstructionTranslator<'a> {

// Load the current cycle counter.
let mut max_cycle =
LLVMBuildLoad2(self.builder, LLVMInt32Type(), self.cycle_ptr(), NONAME);
LLVMBuildLoad2(self.builder, LLVMInt64Type(), self.cycle_ptr(), NONAME);
// Instruction takes at least one cycle even if all dependencies are ready
max_cycle = LLVMBuildAdd(
self.builder,
Expand Down Expand Up @@ -6746,6 +6746,7 @@ impl<'a> InstructionTranslator<'a> {
let ptr = self.reg_ptr(rs);
let data = LLVMBuildLoad2(
self.builder,
// TODO: type is `SsrState`
LLVMInt32Type(),
ptr,
format!("x{}\0", rs).as_ptr() as *const _,
Expand All @@ -6770,7 +6771,7 @@ impl<'a> InstructionTranslator<'a> {
let ptr = self.freg_ptr(rs);
let data = LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt64Type(),
ptr,
format!("f{}\0", rs).as_ptr() as *const _,
);
Expand All @@ -6792,26 +6793,21 @@ impl<'a> InstructionTranslator<'a> {
let raw_ptr = self.freg_ptr(rs);
self.trace_access(
TraceAccess::ReadFReg(rs as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);
let ptr = if llvm_float {
LLVMBuildBitCast(
self.builder,
raw_ptr,
LLVMPointerType(LLVMDoubleType(), 0),
NONAME,
)
let dst_type = if llvm_float {
LLVMFloatType()
} else {

Check warning on line 6800 in src/tran.rs

View workflow job for this annotation

GitHub Actions / Format

Diff in /home/runner/work/banshee/banshee/src/tran.rs
LLVMBuildBitCast(
LLVMDoubleType()
};
let ptr = LLVMBuildBitCast(
self.builder,
raw_ptr,
LLVMPointerType(LLVMInt64Type(), 0),
NONAME,
)
};
LLVMPointerType(dst_type, 0),
NONAME);
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
dst_type,
ptr,
format!("f{}\0", rs).as_ptr() as *const _,
)
Expand All @@ -6834,7 +6830,7 @@ impl<'a> InstructionTranslator<'a> {
let raw_ptr = self.freg_ptr(rs);
self.trace_access(
TraceAccess::ReadFReg(rs as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);
// read data0
let ptr_0 = LLVMBuildBitCast(
Expand Down Expand Up @@ -6951,49 +6947,49 @@ impl<'a> InstructionTranslator<'a> {
(
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt8Type(),
ptr_7,
format!("f{}\0", rs).as_ptr() as *const _,
),
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt8Type(),
ptr_6,
format!("f{}\0", rs).as_ptr() as *const _,
),
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt8Type(),
ptr_5,
format!("f{}\0", rs).as_ptr() as *const _,
),
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt8Type(),
ptr_4,
format!("f{}\0", rs).as_ptr() as *const _,
),
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt8Type(),
ptr_3,
format!("f{}\0", rs).as_ptr() as *const _,
),
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt8Type(),
ptr_2,
format!("f{}\0", rs).as_ptr() as *const _,
),
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt8Type(),
ptr_1,
format!("f{}\0", rs).as_ptr() as *const _,
),
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt8Type(),
ptr_0,
format!("f{}\0", rs).as_ptr() as *const _,
),
Expand All @@ -7008,7 +7004,7 @@ impl<'a> InstructionTranslator<'a> {
let raw_ptr = self.freg_ptr(rs);
self.trace_access(
TraceAccess::Readvf64hReg(rs as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);
// read data0
let ptr_0 = LLVMBuildBitCast(
Expand Down Expand Up @@ -7065,25 +7061,25 @@ impl<'a> InstructionTranslator<'a> {
(
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt16Type(),
ptr_3,
format!("f{}\0", rs).as_ptr() as *const _,
),
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt16Type(),
ptr_2,
format!("f{}\0", rs).as_ptr() as *const _,
),
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt16Type(),
ptr_1,
format!("f{}\0", rs).as_ptr() as *const _,
),
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt16Type(),
ptr_0,
format!("f{}\0", rs).as_ptr() as *const _,
),
Expand All @@ -7095,7 +7091,7 @@ impl<'a> InstructionTranslator<'a> {
let raw_ptr = self.freg_ptr(rs);
self.trace_access(
TraceAccess::Readvf64sReg(rs as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);

// read data1
Expand Down Expand Up @@ -7162,7 +7158,7 @@ impl<'a> InstructionTranslator<'a> {
let raw_ptr = self.freg_ptr(rs);
self.trace_access(
TraceAccess::Readf8Reg(rs as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);
let ptr = LLVMBuildBitCast(
self.builder,
Expand All @@ -7172,7 +7168,7 @@ impl<'a> InstructionTranslator<'a> {
);
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt8Type(),
ptr,
format!("f{}\0", rs).as_ptr() as *const _,
)
Expand All @@ -7184,7 +7180,7 @@ impl<'a> InstructionTranslator<'a> {
let raw_ptr = self.freg_ptr(rs);
self.trace_access(
TraceAccess::Readf16Reg(rs as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);
let ptr = LLVMBuildBitCast(
self.builder,
Expand All @@ -7194,7 +7190,7 @@ impl<'a> InstructionTranslator<'a> {
);
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
LLVMInt16Type(),
ptr,
format!("f{}\0", rs).as_ptr() as *const _,
)
Expand All @@ -7206,26 +7202,22 @@ impl<'a> InstructionTranslator<'a> {
let raw_ptr = self.freg_ptr(rs);
self.trace_access(
TraceAccess::ReadF32Reg(rs as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);
let ptr = if llvm_float {
LLVMBuildBitCast(
self.builder,
raw_ptr,
LLVMPointerType(LLVMFloatType(), 0),
NONAME,
)
let dst_type = if llvm_float {
LLVMFloatType()
} else {

Check warning on line 7209 in src/tran.rs

View workflow job for this annotation

GitHub Actions / Format

Diff in /home/runner/work/banshee/banshee/src/tran.rs
LLVMBuildBitCast(
LLVMInt32Type()
};
let ptr = LLVMBuildBitCast(
self.builder,
raw_ptr,
LLVMPointerType(LLVMInt32Type(), 0),
LLVMPointerType(dst_type, 0),
NONAME,
)
};
);
LLVMBuildLoad2(
self.builder,
LLVMInt32Type(),
dst_type,
ptr,
format!("f{}\0", rs).as_ptr() as *const _,
)
Expand All @@ -7252,7 +7244,7 @@ impl<'a> InstructionTranslator<'a> {
LLVMBuildStore(self.builder, data, ptr);
self.trace_access(
TraceAccess::WriteFReg(rd as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);
self.emit_possible_ssr_write(rd);
}
Expand Down Expand Up @@ -7308,7 +7300,7 @@ impl<'a> InstructionTranslator<'a> {
LLVMBuildStore(self.builder, data2, ptr2);
self.trace_access(
TraceAccess::WriteFReg(rd as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);
self.emit_possible_ssr_write(rd);
}
Expand Down Expand Up @@ -7386,7 +7378,7 @@ impl<'a> InstructionTranslator<'a> {
LLVMBuildStore(self.builder, data3, ptr_3);
self.trace_access(
TraceAccess::Writevf64hReg(rd as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);
self.emit_possible_ssr_write(rd);
}
Expand Down Expand Up @@ -7536,7 +7528,7 @@ impl<'a> InstructionTranslator<'a> {
LLVMBuildStore(self.builder, data7, ptr_7);
self.trace_access(
TraceAccess::WriteFReg(rd as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);
self.emit_possible_ssr_write(rd);
}
Expand Down Expand Up @@ -7597,7 +7589,7 @@ impl<'a> InstructionTranslator<'a> {
LLVMBuildStore(self.builder, data1, ptr_hi);
self.trace_access(
TraceAccess::Writevf64sReg(rd as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);
self.emit_possible_ssr_write(rd);
}
Expand Down Expand Up @@ -7646,7 +7638,7 @@ impl<'a> InstructionTranslator<'a> {
LLVMBuildStore(self.builder, data, ptr);
self.trace_access(
TraceAccess::WriteF32Reg(rd as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), raw_ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), raw_ptr, NONAME),
);
self.emit_possible_ssr_write(rd);
}
Expand All @@ -7663,7 +7655,7 @@ impl<'a> InstructionTranslator<'a> {
LLVMBuildStore(self.builder, value, ptr);
self.trace_access(
TraceAccess::Writef16Reg(rd as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), ptr, NONAME),
);
self.emit_possible_ssr_write(rd);
}
Expand All @@ -7680,7 +7672,7 @@ impl<'a> InstructionTranslator<'a> {
LLVMBuildStore(self.builder, value, ptr);
self.trace_access(
TraceAccess::Writef8Reg(rd as u8),
LLVMBuildLoad2(self.builder, LLVMInt32Type(), ptr, NONAME),
LLVMBuildLoad2(self.builder, LLVMInt64Type(), ptr, NONAME),
);
self.emit_possible_ssr_write(rd);
}
Expand All @@ -7694,6 +7686,7 @@ impl<'a> InstructionTranslator<'a> {

// Check if SSRs are enabled.
let enabled_ptr = self.ssr_enabled_ptr();
// TODO: Check type, this is a `SsrState` pointer
let enabled = LLVMBuildLoad2(self.builder, LLVMInt32Type(), enabled_ptr, NONAME);
let enabled = LLVMBuildTrunc(self.builder, enabled, LLVMInt1Type(), NONAME);

Expand Down Expand Up @@ -7731,6 +7724,7 @@ impl<'a> InstructionTranslator<'a> {

// Check if SSRs are enabled.
let enabled_ptr = self.ssr_enabled_ptr();
// TODO: Check type, this is a `SsrState` pointer
let enabled = LLVMBuildLoad2(self.builder, LLVMInt32Type(), enabled_ptr, NONAME);
let enabled = LLVMBuildTrunc(self.builder, enabled, LLVMInt1Type(), NONAME);

Expand Down

0 comments on commit 862432b

Please sign in to comment.