integrates gen_bool for Conditions (was truncation) into llvm

This commit is contained in:
Eyck-Alexander Jentzsch 2024-07-18 13:30:42 +02:00
parent e1b6cab890
commit 236d12d7f5
1 changed files with 30 additions and 30 deletions

View File

@ -522,10 +522,10 @@ private:
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
auto bb_else = BasicBlock::Create(this->mod->getContext(), "bb_else", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateURem(
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateURem(
new_pc,
this->gen_const(32,static_cast<uint32_t>(traits::INSTR_ALIGNMENT)))
, 1), bb_then, bb_else);
), bb_then, bb_else);
this->builder.SetInsertPoint(bb_then);
{
this->set_tval(new_pc);
@ -589,10 +589,10 @@ private:
else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateICmp(ICmpInst::ICMP_EQ,
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateICmp(ICmpInst::ICMP_EQ,
this->gen_reg_load(rs1+ traits::X0, 0),
this->gen_reg_load(rs2+ traits::X0, 0))
, 1), bb_then, bb_merge);
), bb_then, bb_merge);
this->builder.SetInsertPoint(bb_then);
{
auto new_pc =(uint32_t)(PC+(int16_t)sext<13>(imm));
@ -651,10 +651,10 @@ private:
else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateICmp(ICmpInst::ICMP_NE,
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateICmp(ICmpInst::ICMP_NE,
this->gen_reg_load(rs1+ traits::X0, 0),
this->gen_reg_load(rs2+ traits::X0, 0))
, 1), bb_then, bb_merge);
), bb_then, bb_merge);
this->builder.SetInsertPoint(bb_then);
{
auto new_pc =(uint32_t)(PC+(int16_t)sext<13>(imm));
@ -713,14 +713,14 @@ private:
else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateICmp(ICmpInst::ICMP_SLT,
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateICmp(ICmpInst::ICMP_SLT,
this->gen_ext(
this->gen_reg_load(rs1+ traits::X0, 0),
32, false),
this->gen_ext(
this->gen_reg_load(rs2+ traits::X0, 0),
32, false))
, 1), bb_then, bb_merge);
), bb_then, bb_merge);
this->builder.SetInsertPoint(bb_then);
{
auto new_pc =(uint32_t)(PC+(int16_t)sext<13>(imm));
@ -779,14 +779,14 @@ private:
else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateICmp(ICmpInst::ICMP_SGE,
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateICmp(ICmpInst::ICMP_SGE,
this->gen_ext(
this->gen_reg_load(rs1+ traits::X0, 0),
32, false),
this->gen_ext(
this->gen_reg_load(rs2+ traits::X0, 0),
32, false))
, 1), bb_then, bb_merge);
), bb_then, bb_merge);
this->builder.SetInsertPoint(bb_then);
{
auto new_pc =(uint32_t)(PC+(int16_t)sext<13>(imm));
@ -845,10 +845,10 @@ private:
else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateICmp(ICmpInst::ICMP_ULT,
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateICmp(ICmpInst::ICMP_ULT,
this->gen_reg_load(rs1+ traits::X0, 0),
this->gen_reg_load(rs2+ traits::X0, 0))
, 1), bb_then, bb_merge);
), bb_then, bb_merge);
this->builder.SetInsertPoint(bb_then);
{
auto new_pc =(uint32_t)(PC+(int16_t)sext<13>(imm));
@ -907,10 +907,10 @@ private:
else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateICmp(ICmpInst::ICMP_UGE,
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateICmp(ICmpInst::ICMP_UGE,
this->gen_reg_load(rs1+ traits::X0, 0),
this->gen_reg_load(rs2+ traits::X0, 0))
, 1), bb_then, bb_merge);
), bb_then, bb_merge);
this->builder.SetInsertPoint(bb_then);
{
auto new_pc =(uint32_t)(PC+(int16_t)sext<13>(imm));
@ -3181,17 +3181,17 @@ private:
if(rd!=0){ auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
auto bb_else = BasicBlock::Create(this->mod->getContext(), "bb_else", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateICmp(ICmpInst::ICMP_NE,
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateICmp(ICmpInst::ICMP_NE,
divisor,
this->gen_ext(this->gen_const(8,0), 32,false))
, 1), bb_then, bb_else);
), bb_then, bb_else);
this->builder.SetInsertPoint(bb_then);
{
auto MMIN =((uint32_t)1)<<(static_cast<uint32_t>(traits::XLEN)-1);
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
auto bb_else = BasicBlock::Create(this->mod->getContext(), "bb_else", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateAnd(
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateAnd(
this->builder.CreateICmp(ICmpInst::ICMP_EQ,
this->gen_reg_load(rs1+ traits::X0, 0),
this->gen_const(32,MMIN))
@ -3200,7 +3200,7 @@ private:
divisor,
this->gen_ext(this->gen_const(8,- 1), 32,true))
)
, 1), bb_then, bb_else);
), bb_then, bb_else);
this->builder.SetInsertPoint(bb_then);
{
this->builder.CreateStore(
@ -3277,10 +3277,10 @@ private:
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
auto bb_else = BasicBlock::Create(this->mod->getContext(), "bb_else", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateICmp(ICmpInst::ICMP_NE,
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateICmp(ICmpInst::ICMP_NE,
this->gen_reg_load(rs2+ traits::X0, 0),
this->gen_ext(this->gen_const(8,0), 32,false))
, 1), bb_then, bb_else);
), bb_then, bb_else);
this->builder.SetInsertPoint(bb_then);
{
if(rd!=0) {
@ -3348,17 +3348,17 @@ private:
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
auto bb_else = BasicBlock::Create(this->mod->getContext(), "bb_else", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateICmp(ICmpInst::ICMP_NE,
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateICmp(ICmpInst::ICMP_NE,
this->gen_reg_load(rs2+ traits::X0, 0),
this->gen_ext(this->gen_const(8,0), 32,false))
, 1), bb_then, bb_else);
), bb_then, bb_else);
this->builder.SetInsertPoint(bb_then);
{
auto MMIN =(uint32_t)1<<(static_cast<uint32_t>(traits::XLEN)-1);
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
auto bb_else = BasicBlock::Create(this->mod->getContext(), "bb_else", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateAnd(
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateAnd(
this->builder.CreateICmp(ICmpInst::ICMP_EQ,
this->gen_reg_load(rs1+ traits::X0, 0),
this->gen_const(32,MMIN))
@ -3369,7 +3369,7 @@ private:
32, false),
this->gen_ext(this->gen_const(8,- 1), 32,true))
)
, 1), bb_then, bb_else);
), bb_then, bb_else);
this->builder.SetInsertPoint(bb_then);
{
if(rd!=0) {
@ -3452,10 +3452,10 @@ private:
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
auto bb_else = BasicBlock::Create(this->mod->getContext(), "bb_else", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateICmp(ICmpInst::ICMP_NE,
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateICmp(ICmpInst::ICMP_NE,
this->gen_reg_load(rs2+ traits::X0, 0),
this->gen_ext(this->gen_const(8,0), 32,false))
, 1), bb_then, bb_else);
), bb_then, bb_else);
this->builder.SetInsertPoint(bb_then);
{
if(rd!=0) {
@ -4317,10 +4317,10 @@ private:
/*generate behavior*/
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateICmp(ICmpInst::ICMP_EQ,
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateICmp(ICmpInst::ICMP_EQ,
this->gen_reg_load(rs1+8+ traits::X0, 0),
this->gen_ext(this->gen_const(8,0), 32,false))
, 1), bb_then, bb_merge);
), bb_then, bb_merge);
this->builder.SetInsertPoint(bb_then);
{
auto PC_val_v = (uint32_t)(PC+(int16_t)sext<9>(imm));
@ -4367,10 +4367,10 @@ private:
/*generate behavior*/
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
this->builder.CreateCondBr(this->gen_ext(this->builder.CreateICmp(ICmpInst::ICMP_NE,
this->builder.CreateCondBr(this->gen_bool(this->builder.CreateICmp(ICmpInst::ICMP_NE,
this->gen_reg_load(rs1+8+ traits::X0, 0),
this->gen_ext(this->gen_const(8,0), 32,false))
, 1), bb_then, bb_merge);
), bb_then, bb_merge);
this->builder.SetInsertPoint(bb_then);
{
auto PC_val_v = (uint32_t)(PC+(int16_t)sext<9>(imm));