aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2007-11-05 21:20:28 +0000
committerDale Johannesen <dalej@apple.com>2007-11-05 21:20:28 +0000
commiteb57ea7ea2378b77bc995371c1888193b960cd03 (patch)
treeb09932726b145c3501614679561c699708a4dc48 /lib/CodeGen
parent14ac17e2dfa9cf66dec0da3618badf87163c9bf9 (diff)
Make labels work in asm blocks; allow labels as
parameters. Rename ValueRefList to ParamList in AsmParser, since its only use is for parameters. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43734 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/AsmPrinter.cpp19
-rw-r--r--lib/CodeGen/SelectionDAG/ScheduleDAG.cpp9
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp50
-rw-r--r--lib/CodeGen/SelectionDAG/TargetLowering.cpp9
4 files changed, 53 insertions, 34 deletions
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp
index e7c7448f9b..3500d1245a 100644
--- a/lib/CodeGen/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter.cpp
@@ -1188,13 +1188,18 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
unsigned OpFlags = MI->getOperand(OpNo).getImmedValue();
++OpNo; // Skip over the ID number.
- AsmPrinter *AP = const_cast<AsmPrinter*>(this);
- if ((OpFlags & 7) == 4 /*ADDR MODE*/) {
- Error = AP->PrintAsmMemoryOperand(MI, OpNo, AsmPrinterVariant,
- Modifier[0] ? Modifier : 0);
- } else {
- Error = AP->PrintAsmOperand(MI, OpNo, AsmPrinterVariant,
- Modifier[0] ? Modifier : 0);
+ if (Modifier[0]=='l') // labels are target independent
+ printBasicBlockLabel(MI->getOperand(OpNo).getMachineBasicBlock(),
+ false, false);
+ else {
+ AsmPrinter *AP = const_cast<AsmPrinter*>(this);
+ if ((OpFlags & 7) == 4 /*ADDR MODE*/) {
+ Error = AP->PrintAsmMemoryOperand(MI, OpNo, AsmPrinterVariant,
+ Modifier[0] ? Modifier : 0);
+ } else {
+ Error = AP->PrintAsmOperand(MI, OpNo, AsmPrinterVariant,
+ Modifier[0] ? Modifier : 0);
+ }
}
}
if (Error) {
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
index c98c1312fd..ec84b705bb 100644
--- a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
@@ -803,10 +803,13 @@ void ScheduleDAG::EmitNode(SDNode *Node, unsigned InstanceNo,
if (ConstantSDNode *CS =
dyn_cast<ConstantSDNode>(Node->getOperand(i))) {
MI->addImmOperand(CS->getValue());
- } else {
- GlobalAddressSDNode *GA =
- cast<GlobalAddressSDNode>(Node->getOperand(i));
+ } else if (GlobalAddressSDNode *GA =
+ dyn_cast<GlobalAddressSDNode>(Node->getOperand(i))) {
MI->addGlobalAddressOperand(GA->getGlobal(), GA->getOffset());
+ } else {
+ BasicBlockSDNode *BB =
+ cast<BasicBlockSDNode>(Node->getOperand(i));
+ MI->addMachineBasicBlockOperand(BB->getBasicBlock());
}
}
break;
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 44d8188335..5c2765b916 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -3489,31 +3489,37 @@ void SelectionDAGLowering::visitInlineAsm(CallInst &I) {
}
// If this is an input or an indirect output, process the call argument.
+ // BasicBlocks are labels, currently appearing only in asm's.
if (OpInfo.CallOperandVal) {
- OpInfo.CallOperand = getValue(OpInfo.CallOperandVal);
- const Type *OpTy = OpInfo.CallOperandVal->getType();
- // If this is an indirect operand, the operand is a pointer to the
- // accessed type.
- if (OpInfo.isIndirect)
- OpTy = cast<PointerType>(OpTy)->getElementType();
-
- // If OpTy is not a first-class value, it may be a struct/union that we
- // can tile with integers.
- if (!OpTy->isFirstClassType() && OpTy->isSized()) {
- unsigned BitSize = TD->getTypeSizeInBits(OpTy);
- switch (BitSize) {
- default: break;
- case 1:
- case 8:
- case 16:
- case 32:
- case 64:
- OpTy = IntegerType::get(BitSize);
- break;
+ if (isa<BasicBlock>(OpInfo.CallOperandVal))
+ OpInfo.CallOperand =
+ DAG.getBasicBlock(FuncInfo.MBBMap[cast<BasicBlock>(OpInfo.CallOperandVal)]);
+ else {
+ OpInfo.CallOperand = getValue(OpInfo.CallOperandVal);
+ const Type *OpTy = OpInfo.CallOperandVal->getType();
+ // If this is an indirect operand, the operand is a pointer to the
+ // accessed type.
+ if (OpInfo.isIndirect)
+ OpTy = cast<PointerType>(OpTy)->getElementType();
+
+ // If OpTy is not a first-class value, it may be a struct/union that we
+ // can tile with integers.
+ if (!OpTy->isFirstClassType() && OpTy->isSized()) {
+ unsigned BitSize = TD->getTypeSizeInBits(OpTy);
+ switch (BitSize) {
+ default: break;
+ case 1:
+ case 8:
+ case 16:
+ case 32:
+ case 64:
+ OpTy = IntegerType::get(BitSize);
+ break;
+ }
}
+
+ OpVT = TLI.getValueType(OpTy, true);
}
-
- OpVT = TLI.getValueType(OpTy, true);
}
OpInfo.ConstraintVT = OpVT;
diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index cffb03da52..9309cf46bd 100644
--- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -1396,10 +1396,15 @@ void TargetLowering::LowerAsmOperandForConstraint(SDOperand Op,
SelectionDAG &DAG) {
switch (ConstraintLetter) {
default: break;
+ case 'X': // Allows any operand; labels (basic block) use this.
+ if (Op.getOpcode() == ISD::BasicBlock) {
+ Ops.push_back(Op);
+ return;
+ }
+ // fall through
case 'i': // Simple Integer or Relocatable Constant
case 'n': // Simple Integer
- case 's': // Relocatable Constant
- case 'X': { // Allows any operand.
+ case 's': { // Relocatable Constant
// These operands are interested in values of the form (GV+C), where C may
// be folded in as an offset of GV, or it may be explicitly added. Also, it
// is possible and fine if either GV or C are missing.