@@ -15154,17 +15154,38 @@ PPCTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
15154
15154
return std::make_pair(0U, &PPC::LRRCRegClass);
15155
15155
}
15156
15156
15157
- // If we name a VSX register, we can't defer to the base class because it
15158
- // will not recognize the correct register (their names will be VSL{0-31}
15159
- // and V{0-31} so they won't match). So we match them here.
15160
- if (Constraint.size() > 3 && Constraint[1] == 'v' && Constraint[2] == 's') {
15161
- int VSNum = atoi(Constraint.data() + 3);
15162
- assert(VSNum >= 0 && VSNum <= 63 &&
15163
- "Attempted to access a vsr out of range");
15164
- if (VSNum < 32)
15165
- return std::make_pair(PPC::VSL0 + VSNum, &PPC::VSRCRegClass);
15166
- return std::make_pair(PPC::V0 + VSNum - 32, &PPC::VSRCRegClass);
15157
+ // Handle special cases of physical registers that are not properly handled
15158
+ // by the base class.
15159
+ if (Constraint[0] == '{' && Constraint[Constraint.size() - 1] == '}') {
15160
+ // If we name a VSX register, we can't defer to the base class because it
15161
+ // will not recognize the correct register (their names will be VSL{0-31}
15162
+ // and V{0-31} so they won't match). So we match them here.
15163
+ if (Constraint.size() > 3 && Constraint[1] == 'v' && Constraint[2] == 's') {
15164
+ int VSNum = atoi(Constraint.data() + 3);
15165
+ assert(VSNum >= 0 && VSNum <= 63 &&
15166
+ "Attempted to access a vsr out of range");
15167
+ if (VSNum < 32)
15168
+ return std::make_pair(PPC::VSL0 + VSNum, &PPC::VSRCRegClass);
15169
+ return std::make_pair(PPC::V0 + VSNum - 32, &PPC::VSRCRegClass);
15170
+ }
15171
+
15172
+ // For float registers, we can't defer to the base class as it will match
15173
+ // the SPILLTOVSRRC class.
15174
+ if (Constraint.size() > 3 && Constraint[1] == 'f') {
15175
+ int RegNum = atoi(Constraint.data() + 2);
15176
+ if (RegNum > 31 || RegNum < 0)
15177
+ report_fatal_error("Invalid floating point register number");
15178
+ if (VT == MVT::f32 || VT == MVT::i32)
15179
+ return Subtarget.hasSPE()
15180
+ ? std::make_pair(PPC::R0 + RegNum, &PPC::GPRCRegClass)
15181
+ : std::make_pair(PPC::F0 + RegNum, &PPC::F4RCRegClass);
15182
+ if (VT == MVT::f64 || VT == MVT::i64)
15183
+ return Subtarget.hasSPE()
15184
+ ? std::make_pair(PPC::S0 + RegNum, &PPC::SPERCRegClass)
15185
+ : std::make_pair(PPC::F0 + RegNum, &PPC::F8RCRegClass);
15186
+ }
15167
15187
}
15188
+
15168
15189
std::pair<unsigned, const TargetRegisterClass *> R =
15169
15190
TargetLowering::getRegForInlineAsmConstraint(TRI, Constraint, VT);
15170
15191
0 commit comments