llvm.org GIT mirror llvm / 827b7a0
Add support for the PowerPC-specific inline asm Z constraint and y modifier. The Z constraint specifies an r+r memory address, and the y modifier expands to the "r, r" in the asm string. For this initial implementation, the base register is forced to r0 (which has the special meaning of 0 for r+r addressing on PowerPC) and the full address is taken in the second register. In the future, this should be improved. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167388 91177308-0d34-0410-b5e6-96231b3b80d8 Hal Finkel 7 years ago
3 changed file(s) with 41 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
283283 unsigned AsmVariant,
284284 const char *ExtraCode,
285285 raw_ostream &O) {
286 if (ExtraCode && ExtraCode[0])
287 return true; // Unknown modifier.
286 if (ExtraCode && ExtraCode[0]) {
287 if (ExtraCode[1] != 0) return true; // Unknown modifier.
288
289 switch (ExtraCode[0]) {
290 default: return true; // Unknown modifier.
291 case 'y': // A memory reference for an X-form instruction
292 {
293 const char *RegName = "r0";
294 if (!Subtarget.isDarwin()) RegName = stripRegisterPrefix(RegName);
295 O << RegName << ", ";
296 printOperand(MI, OpNo, O);
297 return false;
298 }
299 }
300 }
301
288302 assert(MI->getOperand(OpNo).isReg());
289303 O << "0(";
290304 printOperand(MI, OpNo, O);
64426442 case 'v':
64436443 case 'y':
64446444 return C_RegisterClass;
6445 case 'Z':
6446 // FIXME: While Z does indicate a memory constraint, it specifically
6447 // indicates an r+r address (used in conjunction with the 'y' modifier
6448 // in the replacement string). Currently, we're forcing the base
6449 // register to be r0 in the asm printer (which is interpreted as zero)
6450 // and forming the complete address in the second register. This is
6451 // suboptimal.
6452 return C_Memory;
64456453 }
64466454 }
64476455 return TargetLowering::getConstraintType(Constraint);
64836491 break;
64846492 case 'y':
64856493 weight = CW_Register;
6494 break;
6495 case 'Z':
6496 weight = CW_Memory;
64866497 break;
64876498 }
64886499 return weight;
0 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
1 target triple = "powerpc64-bgq-linux"
2 ; RUN: llc < %s -march=ppc64 -mcpu=a2 | FileCheck %s
3
4 define i32 @zytest(i32 %a) nounwind {
5 entry:
6 ; CHECK: @zytest
7 %r = call i32 asm "lwbrx $0, ${1:y}", "=r,Z"(i32 %a) nounwind, !srcloc !0
8 ret i32 %r
9 ; CHECK: lwbrx 3, 0,
10 }
11
12 !0 = metadata !{i32 101688}
13