88#include " ../Target.h"
99#include " AArch64.h"
1010#include " AArch64RegisterInfo.h"
11+ #include < iostream>
1112
1213#define GET_AVAILABLE_OPCODE_CHECKER
1314#include " AArch64GenInstrInfo.inc"
@@ -38,13 +39,13 @@ static MCInst loadImmediate(MCRegister Reg, unsigned RegBitWidth,
3839
3940static MCInst loadZPRImmediate (MCRegister Reg, unsigned RegBitWidth,
4041 const APInt &Value) {
41- // 0 <= Value.getZExtValue() < 2**13
42- assert (Value.getZExtValue () < (1 << 13 ) &&
42+ // -127 <= Value.getZExtValue() < 128
43+ assert (Value.getZExtValue () < (1 << 7 ) &&
4344 " Value must be in the range of the immediate opcode" );
44- // For ZPR, we typically use DUPM instruction to load immediate values
45- return MCInstBuilder (AArch64::DUPM_ZI)
45+ return MCInstBuilder (AArch64::DUP_ZI_D)
4646 .addReg (Reg)
47- .addImm (Value.getZExtValue ());
47+ .addImm (Value.getZExtValue ())
48+ .addImm (0 );
4849}
4950
5051static MCInst loadPPRImmediate (MCRegister Reg, unsigned RegBitWidth,
@@ -59,7 +60,7 @@ static MCInst loadPPRImmediate(MCRegister Reg, unsigned RegBitWidth,
5960static unsigned getLoadFPImmediateOpcode (unsigned RegBitWidth) {
6061 switch (RegBitWidth) {
6162 case 64 :
62- return AArch64::FMOVDi;
63+ return AArch64::MOVID; // FMOVDi;
6364 case 128 :
6465 return AArch64::MOVIv2d_ns;
6566 }
@@ -69,18 +70,10 @@ static unsigned getLoadFPImmediateOpcode(unsigned RegBitWidth) {
6970// Generates instruction to load an FP immediate value into a register.
7071static MCInst loadFPImmediate (MCRegister Reg, unsigned RegBitWidth,
7172 const APInt &Value) {
72- // -31 <= Value.getZExtValue() <= 31
73- assert (Value.getZExtValue () <= 31 &&
74- " Value must be in the range of the immediate opcode" );
75- return MCInstBuilder (getLoadFPImmediateOpcode (RegBitWidth))
76- .addReg (Reg)
77- .addImm (Value.getZExtValue ());
78- }
79-
80- // Generates instruction to load an FP128 immediate value into a register.
81- static MCInst loadFP128Immediate (MCRegister Reg, unsigned RegBitWidth,
82- const APInt &Value) {
83- // 0 <= Value.getZExtValue() < 2**8
73+ // 0 <= Value.getZExtValue() < 2**8 (int Value)
74+ // -31.0 <= Value.getZExtValue() < 31.0 (frac Value)
75+ assert (Value.getZExtValue () == 0 &&
76+ " Value should be zero, temporary fix for now" );
8477 assert (Value.getZExtValue () < (1 << 8 ) &&
8578 " Value must be in the range of the immediate opcode" );
8679 return MCInstBuilder (getLoadFPImmediateOpcode (RegBitWidth))
@@ -109,7 +102,7 @@ class ExegesisAArch64Target : public ExegesisTarget {
109102 if (AArch64::FPR64RegClass.contains (Reg))
110103 return {loadFPImmediate (Reg, 64 , Value)};
111104 if (AArch64::FPR128RegClass.contains (Reg))
112- return {loadFP128Immediate (Reg, 128 , Value)};
105+ return {loadFPImmediate (Reg, 128 , Value)};
113106 if (AArch64::ZPRRegClass.contains (Reg))
114107 return {loadZPRImmediate (Reg, 128 , Value)};
115108
0 commit comments