Commit 953568f8 by Reed Kotler Committed by Jim Stichnoth

This would eliminate a lot of repetitive coding in subzero.

It's troublesome that we have to type (this) in several places but I don't see a away around it yet and it does not add to the line of code count at all to have to do this; it's just not aesthetic to me. If this idea is okay, I can make all the similar changes in the Mips Subzero port. BUG= Review URL: https://codereview.chromium.org/1661233002 . Patch from Reed Kotler <rkotlerimgtec@gmail.com>.
parent 4b6e4b44
...@@ -599,10 +599,8 @@ void TargetMIPS32::lowerInt64Arithmetic(const InstArithmetic *Instr, ...@@ -599,10 +599,8 @@ void TargetMIPS32::lowerInt64Arithmetic(const InstArithmetic *Instr,
llvm::report_fatal_error("Unknown arithmetic operator"); llvm::report_fatal_error("Unknown arithmetic operator");
return; return;
case InstArithmetic::Add: { case InstArithmetic::Add: {
Variable *T_Carry = makeReg(IceType_i32); auto *T_Carry = I32Reg(), *T_Lo = I32Reg(), *T_Hi = I32Reg(),
Variable *T_Lo = makeReg(IceType_i32); *T_Hi2 = I32Reg();
Variable *T_Hi = makeReg(IceType_i32);
Variable *T_Hi2 = makeReg(IceType_i32);
_addu(T_Lo, Src0LoR, Src1LoR); _addu(T_Lo, Src0LoR, Src1LoR);
_mov(DestLo, T_Lo); _mov(DestLo, T_Lo);
_sltu(T_Carry, T_Lo, Src0LoR); _sltu(T_Carry, T_Lo, Src0LoR);
...@@ -612,8 +610,7 @@ void TargetMIPS32::lowerInt64Arithmetic(const InstArithmetic *Instr, ...@@ -612,8 +610,7 @@ void TargetMIPS32::lowerInt64Arithmetic(const InstArithmetic *Instr,
return; return;
} }
case InstArithmetic::And: { case InstArithmetic::And: {
Variable *T_Lo = makeReg(IceType_i32); auto *T_Lo = I32Reg(), *T_Hi = I32Reg();
Variable *T_Hi = makeReg(IceType_i32);
_and(T_Lo, Src0LoR, Src1LoR); _and(T_Lo, Src0LoR, Src1LoR);
_mov(DestLo, T_Lo); _mov(DestLo, T_Lo);
_and(T_Hi, Src0HiR, Src1HiR); _and(T_Hi, Src0HiR, Src1HiR);
...@@ -621,10 +618,8 @@ void TargetMIPS32::lowerInt64Arithmetic(const InstArithmetic *Instr, ...@@ -621,10 +618,8 @@ void TargetMIPS32::lowerInt64Arithmetic(const InstArithmetic *Instr,
return; return;
} }
case InstArithmetic::Sub: { case InstArithmetic::Sub: {
Variable *T_Borrow = makeReg(IceType_i32); auto *T_Borrow = I32Reg(), *T_Lo = I32Reg(), *T_Hi = I32Reg(),
Variable *T_Lo = makeReg(IceType_i32); *T_Hi2 = I32Reg();
Variable *T_Hi = makeReg(IceType_i32);
Variable *T_Hi2 = makeReg(IceType_i32);
_subu(T_Lo, Src0LoR, Src1LoR); _subu(T_Lo, Src0LoR, Src1LoR);
_mov(DestLo, T_Lo); _mov(DestLo, T_Lo);
_sltu(T_Borrow, Src0LoR, Src1LoR); _sltu(T_Borrow, Src0LoR, Src1LoR);
...@@ -634,8 +629,7 @@ void TargetMIPS32::lowerInt64Arithmetic(const InstArithmetic *Instr, ...@@ -634,8 +629,7 @@ void TargetMIPS32::lowerInt64Arithmetic(const InstArithmetic *Instr,
return; return;
} }
case InstArithmetic::Or: { case InstArithmetic::Or: {
Variable *T_Lo = makeReg(IceType_i32); auto *T_Lo = I32Reg(), *T_Hi = I32Reg();
Variable *T_Hi = makeReg(IceType_i32);
_or(T_Lo, Src0LoR, Src1LoR); _or(T_Lo, Src0LoR, Src1LoR);
_mov(DestLo, T_Lo); _mov(DestLo, T_Lo);
_or(T_Hi, Src0HiR, Src1HiR); _or(T_Hi, Src0HiR, Src1HiR);
...@@ -643,8 +637,7 @@ void TargetMIPS32::lowerInt64Arithmetic(const InstArithmetic *Instr, ...@@ -643,8 +637,7 @@ void TargetMIPS32::lowerInt64Arithmetic(const InstArithmetic *Instr,
return; return;
} }
case InstArithmetic::Xor: { case InstArithmetic::Xor: {
Variable *T_Lo = makeReg(IceType_i32); auto *T_Lo = I32Reg(), *T_Hi = I32Reg();
Variable *T_Hi = makeReg(IceType_i32);
_xor(T_Lo, Src0LoR, Src1LoR); _xor(T_Lo, Src0LoR, Src1LoR);
_mov(DestLo, T_Lo); _mov(DestLo, T_Lo);
_xor(T_Hi, Src0HiR, Src1HiR); _xor(T_Hi, Src0HiR, Src1HiR);
...@@ -765,8 +758,7 @@ void TargetMIPS32::lowerAssign(const InstAssign *Instr) { ...@@ -765,8 +758,7 @@ void TargetMIPS32::lowerAssign(const InstAssign *Instr) {
auto *DestLo = llvm::cast<Variable>(loOperand(Dest)); auto *DestLo = llvm::cast<Variable>(loOperand(Dest));
auto *DestHi = llvm::cast<Variable>(hiOperand(Dest)); auto *DestHi = llvm::cast<Variable>(hiOperand(Dest));
// Variable *T_Lo = nullptr, *T_Hi = nullptr; // Variable *T_Lo = nullptr, *T_Hi = nullptr;
Variable *T_Lo = makeReg(IceType_i32); auto *T_Lo = I32Reg(), *T_Hi = I32Reg();
Variable *T_Hi = makeReg(IceType_i32);
_mov(T_Lo, Src0Lo); _mov(T_Lo, Src0Lo);
_mov(DestLo, T_Lo); _mov(DestLo, T_Lo);
_mov(T_Hi, Src0Hi); _mov(T_Hi, Src0Hi);
...@@ -822,8 +814,8 @@ void TargetMIPS32::lowerCall(const InstCall *Instr) { ...@@ -822,8 +814,8 @@ void TargetMIPS32::lowerCall(const InstCall *Instr) {
ReturnReg = makeReg(Dest->getType(), RegMIPS32::Reg_V0); ReturnReg = makeReg(Dest->getType(), RegMIPS32::Reg_V0);
break; break;
case IceType_i64: case IceType_i64:
ReturnReg = makeReg(IceType_i32, RegMIPS32::Reg_V0); ReturnReg = I32Reg(RegMIPS32::Reg_V0);
ReturnRegHi = makeReg(IceType_i32, RegMIPS32::Reg_V1); ReturnRegHi = I32Reg(RegMIPS32::Reg_V1);
break; break;
case IceType_f32: case IceType_f32:
case IceType_f64: case IceType_f64:
......
...@@ -227,6 +227,11 @@ public: ...@@ -227,6 +227,11 @@ public:
Variable *legalizeToReg(Operand *From, RegNumT RegNum = RegNumT()); Variable *legalizeToReg(Operand *From, RegNumT RegNum = RegNumT());
Variable *makeReg(Type Ty, RegNumT RegNum = RegNumT()); Variable *makeReg(Type Ty, RegNumT RegNum = RegNumT());
Variable *I32Reg(RegNumT RegNum = RegNumT()) {
return makeReg(IceType_i32, RegNum);
}
static Type stackSlotType(); static Type stackSlotType();
Variable *copyToReg(Operand *Src, RegNumT RegNum = RegNumT()); Variable *copyToReg(Operand *Src, RegNumT RegNum = RegNumT());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment