diff options
author | 2015-09-16 04:21:39 +0000 | |
---|---|---|
committer | 2015-09-16 04:21:39 +0000 | |
commit | e295be4a95d7861f6ec179edf6565f58cad747cc (patch) | |
tree | a994a7f270e8dd81e3bb1a704c4ee5f6ea98aa7c /compiler | |
parent | 9ea4a93674b42f213334bb83d1982db11091b96a (diff) | |
parent | 2fadd7bb67abf5bc3c5370f9508cfb5959d6e536 (diff) |
Merge "Additional MIPS64 instructions needed by intrinsics code."
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/utils/mips64/assembler_mips64.cc | 202 | ||||
-rw-r--r-- | compiler/utils/mips64/assembler_mips64.h | 45 |
2 files changed, 247 insertions, 0 deletions
diff --git a/compiler/utils/mips64/assembler_mips64.cc b/compiler/utils/mips64/assembler_mips64.cc index 24ea9e25db..b078f3e4cf 100644 --- a/compiler/utils/mips64/assembler_mips64.cc +++ b/compiler/utils/mips64/assembler_mips64.cc @@ -44,6 +44,32 @@ void Mips64Assembler::EmitR(int opcode, GpuRegister rs, GpuRegister rt, GpuRegis Emit(encoding); } +void Mips64Assembler::EmitRsd(int opcode, GpuRegister rs, GpuRegister rd, + int shamt, int funct) { + CHECK_NE(rs, kNoGpuRegister); + CHECK_NE(rd, kNoGpuRegister); + uint32_t encoding = static_cast<uint32_t>(opcode) << kOpcodeShift | + static_cast<uint32_t>(rs) << kRsShift | + static_cast<uint32_t>(ZERO) << kRtShift | + static_cast<uint32_t>(rd) << kRdShift | + shamt << kShamtShift | + funct; + Emit(encoding); +} + +void Mips64Assembler::EmitRtd(int opcode, GpuRegister rt, GpuRegister rd, + int shamt, int funct) { + CHECK_NE(rt, kNoGpuRegister); + CHECK_NE(rd, kNoGpuRegister); + uint32_t encoding = static_cast<uint32_t>(opcode) << kOpcodeShift | + static_cast<uint32_t>(ZERO) << kRsShift | + static_cast<uint32_t>(rt) << kRtShift | + static_cast<uint32_t>(rd) << kRdShift | + shamt << kShamtShift | + funct; + Emit(encoding); +} + void Mips64Assembler::EmitI(int opcode, GpuRegister rs, GpuRegister rt, uint16_t imm) { CHECK_NE(rs, kNoGpuRegister); CHECK_NE(rt, kNoGpuRegister); @@ -235,6 +261,14 @@ void Mips64Assembler::Nor(GpuRegister rd, GpuRegister rs, GpuRegister rt) { EmitR(0, rs, rt, rd, 0, 0x27); } +void Mips64Assembler::Bitswap(GpuRegister rd, GpuRegister rt) { + EmitRtd(0x1f, rt, rd, 0x0, 0x20); +} + +void Mips64Assembler::Dbitswap(GpuRegister rd, GpuRegister rt) { + EmitRtd(0x1f, rt, rd, 0x0, 0x24); +} + void Mips64Assembler::Seb(GpuRegister rd, GpuRegister rt) { EmitR(0x1f, static_cast<GpuRegister>(0), rt, rd, 0x10, 0x20); } @@ -243,12 +277,44 @@ void Mips64Assembler::Seh(GpuRegister rd, GpuRegister rt) { EmitR(0x1f, static_cast<GpuRegister>(0), rt, rd, 0x18, 0x20); } +void Mips64Assembler::Dsbh(GpuRegister rd, GpuRegister rt) { + EmitRtd(0x1f, rt, rd, 0x2, 0x24); +} + +void Mips64Assembler::Dshd(GpuRegister rd, GpuRegister rt) { + EmitRtd(0x1f, rt, rd, 0x5, 0x24); +} + void Mips64Assembler::Dext(GpuRegister rt, GpuRegister rs, int pos, int size_less_one) { DCHECK(0 <= pos && pos < 32) << pos; DCHECK(0 <= size_less_one && size_less_one < 32) << size_less_one; EmitR(0x1f, rs, rt, static_cast<GpuRegister>(size_less_one), pos, 3); } +void Mips64Assembler::Wsbh(GpuRegister rd, GpuRegister rt) { + EmitRtd(0x1f, rt, rd, 2, 0x20); +} + +void Mips64Assembler::Sc(GpuRegister rt, GpuRegister base, int16_t imm9) { + DCHECK((-256 <= imm9) && (imm9 < 256)); + EmitI(0x1f, base, rt, ((imm9 & 0x1FF) << 7) | 0x26); +} + +void Mips64Assembler::Scd(GpuRegister rt, GpuRegister base, int16_t imm9) { + DCHECK((-256 <= imm9) && (imm9 < 256)); + EmitI(0x1f, base, rt, ((imm9 & 0x1FF) << 7) | 0x27); +} + +void Mips64Assembler::Ll(GpuRegister rt, GpuRegister base, int16_t imm9) { + DCHECK((-256 <= imm9) && (imm9 < 256)); + EmitI(0x1f, base, rt, ((imm9 & 0x1FF) << 7) | 0x36); +} + +void Mips64Assembler::Lld(GpuRegister rt, GpuRegister base, int16_t imm9) { + DCHECK((-256 <= imm9) && (imm9 < 256)); + EmitI(0x1f, base, rt, ((imm9 & 0x1FF) << 7) | 0x37); +} + void Mips64Assembler::Sll(GpuRegister rd, GpuRegister rt, int shamt) { EmitR(0, static_cast<GpuRegister>(0), rt, rd, shamt, 0x00); } @@ -257,6 +323,10 @@ void Mips64Assembler::Srl(GpuRegister rd, GpuRegister rt, int shamt) { EmitR(0, static_cast<GpuRegister>(0), rt, rd, shamt, 0x02); } +void Mips64Assembler::Rotr(GpuRegister rd, GpuRegister rt, int shamt) { + EmitR(0, static_cast<GpuRegister>(1), rt, rd, shamt, 0x02); +} + void Mips64Assembler::Sra(GpuRegister rd, GpuRegister rt, int shamt) { EmitR(0, static_cast<GpuRegister>(0), rt, rd, shamt, 0x03); } @@ -414,6 +484,30 @@ void Mips64Assembler::Jal(uint32_t addr26) { Nop(); } +void Mips64Assembler::Seleqz(GpuRegister rd, GpuRegister rs, GpuRegister rt) { + EmitR(0, rs, rt, rd, 0, 0x35); +} + +void Mips64Assembler::Selnez(GpuRegister rd, GpuRegister rs, GpuRegister rt) { + EmitR(0, rs, rt, rd, 0, 0x37); +} + +void Mips64Assembler::Clz(GpuRegister rd, GpuRegister rs) { + EmitRsd(0, rs, rd, 0x01, 0x10); +} + +void Mips64Assembler::Clo(GpuRegister rd, GpuRegister rs) { + EmitRsd(0, rs, rd, 0x01, 0x11); +} + +void Mips64Assembler::Dclz(GpuRegister rd, GpuRegister rs) { + EmitRsd(0, rs, rd, 0x01, 0x12); +} + +void Mips64Assembler::Dclo(GpuRegister rd, GpuRegister rs) { + EmitRsd(0, rs, rd, 0x01, 0x13); +} + void Mips64Assembler::Jalr(GpuRegister rd, GpuRegister rs) { EmitR(0, rs, static_cast<GpuRegister>(0), rd, 0, 0x09); Nop(); @@ -543,6 +637,22 @@ void Mips64Assembler::DivD(FpuRegister fd, FpuRegister fs, FpuRegister ft) { EmitFR(0x11, 0x11, ft, fs, fd, 0x3); } +void Mips64Assembler::SqrtS(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x10, static_cast<FpuRegister>(0), fs, fd, 0x4); +} + +void Mips64Assembler::SqrtD(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x11, static_cast<FpuRegister>(0), fs, fd, 0x4); +} + +void Mips64Assembler::AbsS(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x10, static_cast<FpuRegister>(0), fs, fd, 0x5); +} + +void Mips64Assembler::AbsD(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x11, static_cast<FpuRegister>(0), fs, fd, 0x5); +} + void Mips64Assembler::MovS(FpuRegister fd, FpuRegister fs) { EmitFR(0x11, 0x10, static_cast<FpuRegister>(0), fs, fd, 0x6); } @@ -559,6 +669,94 @@ void Mips64Assembler::NegD(FpuRegister fd, FpuRegister fs) { EmitFR(0x11, 0x11, static_cast<FpuRegister>(0), fs, fd, 0x7); } +void Mips64Assembler::RoundLS(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x10, static_cast<FpuRegister>(0), fs, fd, 0x8); +} + +void Mips64Assembler::RoundLD(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x11, static_cast<FpuRegister>(0), fs, fd, 0x8); +} + +void Mips64Assembler::RoundWS(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x10, static_cast<FpuRegister>(0), fs, fd, 0xc); +} + +void Mips64Assembler::RoundWD(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x11, static_cast<FpuRegister>(0), fs, fd, 0xc); +} + +void Mips64Assembler::CeilLS(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x10, static_cast<FpuRegister>(0), fs, fd, 0xa); +} + +void Mips64Assembler::CeilLD(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x11, static_cast<FpuRegister>(0), fs, fd, 0xa); +} + +void Mips64Assembler::CeilWS(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x10, static_cast<FpuRegister>(0), fs, fd, 0xe); +} + +void Mips64Assembler::CeilWD(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x11, static_cast<FpuRegister>(0), fs, fd, 0xe); +} + +void Mips64Assembler::FloorLS(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x10, static_cast<FpuRegister>(0), fs, fd, 0xb); +} + +void Mips64Assembler::FloorLD(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x11, static_cast<FpuRegister>(0), fs, fd, 0xb); +} + +void Mips64Assembler::FloorWS(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x10, static_cast<FpuRegister>(0), fs, fd, 0xf); +} + +void Mips64Assembler::FloorWD(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x11, static_cast<FpuRegister>(0), fs, fd, 0xf); +} + +void Mips64Assembler::SelS(FpuRegister fd, FpuRegister fs, FpuRegister ft) { + EmitFR(0x11, 0x10, ft, fs, fd, 0x10); +} + +void Mips64Assembler::SelD(FpuRegister fd, FpuRegister fs, FpuRegister ft) { + EmitFR(0x11, 0x11, ft, fs, fd, 0x10); +} + +void Mips64Assembler::RintS(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x10, static_cast<FpuRegister>(0), fs, fd, 0x1a); +} + +void Mips64Assembler::RintD(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x11, static_cast<FpuRegister>(0), fs, fd, 0x1a); +} + +void Mips64Assembler::ClassS(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x10, static_cast<FpuRegister>(0), fs, fd, 0x1b); +} + +void Mips64Assembler::ClassD(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x11, static_cast<FpuRegister>(0), fs, fd, 0x1b); +} + +void Mips64Assembler::MinS(FpuRegister fd, FpuRegister fs, FpuRegister ft) { + EmitFR(0x11, 0x10, ft, fs, fd, 0x1c); +} + +void Mips64Assembler::MinD(FpuRegister fd, FpuRegister fs, FpuRegister ft) { + EmitFR(0x11, 0x11, ft, fs, fd, 0x1c); +} + +void Mips64Assembler::MaxS(FpuRegister fd, FpuRegister fs, FpuRegister ft) { + EmitFR(0x11, 0x10, ft, fs, fd, 0x1e); +} + +void Mips64Assembler::MaxD(FpuRegister fd, FpuRegister fs, FpuRegister ft) { + EmitFR(0x11, 0x11, ft, fs, fd, 0x1e); +} + void Mips64Assembler::Cvtsw(FpuRegister fd, FpuRegister fs) { EmitFR(0x11, 0x14, static_cast<FpuRegister>(0), fs, fd, 0x20); } @@ -575,6 +773,10 @@ void Mips64Assembler::Cvtds(FpuRegister fd, FpuRegister fs) { EmitFR(0x11, 0x10, static_cast<FpuRegister>(0), fs, fd, 0x21); } +void Mips64Assembler::Cvtdl(FpuRegister fd, FpuRegister fs) { + EmitFR(0x11, 0x15, static_cast<FpuRegister>(0), fs, fd, 0x21); +} + void Mips64Assembler::Mfc1(GpuRegister rt, FpuRegister fs) { EmitFR(0x11, 0x00, static_cast<FpuRegister>(rt), fs, static_cast<FpuRegister>(0), 0x0); } diff --git a/compiler/utils/mips64/assembler_mips64.h b/compiler/utils/mips64/assembler_mips64.h index 31130ea43d..a120abb238 100644 --- a/compiler/utils/mips64/assembler_mips64.h +++ b/compiler/utils/mips64/assembler_mips64.h @@ -90,12 +90,22 @@ class Mips64Assembler FINAL : public Assembler { void Xori(GpuRegister rt, GpuRegister rs, uint16_t imm16); void Nor(GpuRegister rd, GpuRegister rs, GpuRegister rt); + void Bitswap(GpuRegister rd, GpuRegister rt); // R6 + void Dbitswap(GpuRegister rd, GpuRegister rt); // R6 void Seb(GpuRegister rd, GpuRegister rt); // R2+ void Seh(GpuRegister rd, GpuRegister rt); // R2+ + void Dsbh(GpuRegister rd, GpuRegister rt); // R2+ + void Dshd(GpuRegister rd, GpuRegister rt); // R2+ void Dext(GpuRegister rs, GpuRegister rt, int pos, int size_less_one); // MIPS64 + void Wsbh(GpuRegister rd, GpuRegister rt); + void Sc(GpuRegister rt, GpuRegister base, int16_t imm9 = 0); + void Scd(GpuRegister rt, GpuRegister base, int16_t imm9 = 0); + void Ll(GpuRegister rt, GpuRegister base, int16_t imm9 = 0); + void Lld(GpuRegister rt, GpuRegister base, int16_t imm9 = 0); void Sll(GpuRegister rd, GpuRegister rt, int shamt); void Srl(GpuRegister rd, GpuRegister rt, int shamt); + void Rotr(GpuRegister rd, GpuRegister rt, int shamt); void Sra(GpuRegister rd, GpuRegister rt, int shamt); void Sllv(GpuRegister rd, GpuRegister rt, GpuRegister rs); void Srlv(GpuRegister rd, GpuRegister rt, GpuRegister rs); @@ -133,6 +143,12 @@ class Mips64Assembler FINAL : public Assembler { void Sltu(GpuRegister rd, GpuRegister rs, GpuRegister rt); void Slti(GpuRegister rt, GpuRegister rs, uint16_t imm16); void Sltiu(GpuRegister rt, GpuRegister rs, uint16_t imm16); + void Seleqz(GpuRegister rd, GpuRegister rs, GpuRegister rt); + void Selnez(GpuRegister rd, GpuRegister rs, GpuRegister rt); + void Clz(GpuRegister rd, GpuRegister rs); + void Clo(GpuRegister rd, GpuRegister rs); + void Dclz(GpuRegister rd, GpuRegister rs); + void Dclo(GpuRegister rd, GpuRegister rs); void Beq(GpuRegister rs, GpuRegister rt, uint16_t imm16); void Bne(GpuRegister rs, GpuRegister rt, uint16_t imm16); @@ -165,15 +181,42 @@ class Mips64Assembler FINAL : public Assembler { void SubD(FpuRegister fd, FpuRegister fs, FpuRegister ft); void MulD(FpuRegister fd, FpuRegister fs, FpuRegister ft); void DivD(FpuRegister fd, FpuRegister fs, FpuRegister ft); + void SqrtS(FpuRegister fd, FpuRegister fs); + void SqrtD(FpuRegister fd, FpuRegister fs); + void AbsS(FpuRegister fd, FpuRegister fs); + void AbsD(FpuRegister fd, FpuRegister fs); void MovS(FpuRegister fd, FpuRegister fs); void MovD(FpuRegister fd, FpuRegister fs); void NegS(FpuRegister fd, FpuRegister fs); void NegD(FpuRegister fd, FpuRegister fs); + void RoundLS(FpuRegister fd, FpuRegister fs); + void RoundLD(FpuRegister fd, FpuRegister fs); + void RoundWS(FpuRegister fd, FpuRegister fs); + void RoundWD(FpuRegister fd, FpuRegister fs); + void CeilLS(FpuRegister fd, FpuRegister fs); + void CeilLD(FpuRegister fd, FpuRegister fs); + void CeilWS(FpuRegister fd, FpuRegister fs); + void CeilWD(FpuRegister fd, FpuRegister fs); + void FloorLS(FpuRegister fd, FpuRegister fs); + void FloorLD(FpuRegister fd, FpuRegister fs); + void FloorWS(FpuRegister fd, FpuRegister fs); + void FloorWD(FpuRegister fd, FpuRegister fs); + void SelS(FpuRegister fd, FpuRegister fs, FpuRegister ft); + void SelD(FpuRegister fd, FpuRegister fs, FpuRegister ft); + void RintS(FpuRegister fd, FpuRegister fs); + void RintD(FpuRegister fd, FpuRegister fs); + void ClassS(FpuRegister fd, FpuRegister fs); + void ClassD(FpuRegister fd, FpuRegister fs); + void MinS(FpuRegister fd, FpuRegister fs, FpuRegister ft); + void MinD(FpuRegister fd, FpuRegister fs, FpuRegister ft); + void MaxS(FpuRegister fd, FpuRegister fs, FpuRegister ft); + void MaxD(FpuRegister fd, FpuRegister fs, FpuRegister ft); void Cvtsw(FpuRegister fd, FpuRegister fs); void Cvtdw(FpuRegister fd, FpuRegister fs); void Cvtsd(FpuRegister fd, FpuRegister fs); void Cvtds(FpuRegister fd, FpuRegister fs); + void Cvtdl(FpuRegister fd, FpuRegister fs); void Mfc1(GpuRegister rt, FpuRegister fs); void Mtc1(GpuRegister rt, FpuRegister fs); @@ -342,6 +385,8 @@ class Mips64Assembler FINAL : public Assembler { private: void EmitR(int opcode, GpuRegister rs, GpuRegister rt, GpuRegister rd, int shamt, int funct); + void EmitRsd(int opcode, GpuRegister rs, GpuRegister rd, int shamt, int funct); + void EmitRtd(int opcode, GpuRegister rt, GpuRegister rd, int shamt, int funct); void EmitI(int opcode, GpuRegister rs, GpuRegister rt, uint16_t imm); void EmitI21(int opcode, GpuRegister rs, uint32_t imm21); void EmitJ(int opcode, uint32_t addr26); |