llvm.org GIT mirror llvm / 43f44aa
improve x86 codegen support for blockaddress. We now compile the testcase into: _test1: ## @test1 ## BB#0: ## %entry leaq L_test1_bb6(%rip), %rax jmpq *%rax L_test1_bb: ## Address Taken LBB1_1: ## %bb movb $1, %al ret L_test1_bb6: ## Address Taken LBB1_2: ## %bb6 movb $2, %al ret Note, it is very very strange that BlockAddressSDNode doesn't carry around TargetFlags. Dan, please fix this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85703 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
2 changed file(s) with 30 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
7070 SDValue Segment;
7171 GlobalValue *GV;
7272 Constant *CP;
73 BlockAddress *BlockAddr;
7374 const char *ES;
7475 int JT;
7576 unsigned Align; // CP alignment.
7778
7879 X86ISelAddressMode()
7980 : BaseType(RegBase), Scale(1), IndexReg(), Disp(0),
80 Segment(), GV(0), CP(0), ES(0), JT(-1), Align(0),
81 Segment(), GV(0), CP(0), BlockAddr(0), ES(0), JT(-1), Align(0),
8182 SymbolFlags(X86II::MO_NO_FLAG) {
8283 }
8384
8485 bool hasSymbolicDisplacement() const {
85 return GV != 0 || CP != 0 || ES != 0 || JT != -1;
86 return GV != 0 || CP != 0 || ES != 0 || JT != -1 || BlockAddr != 0;
8687 }
8788
8889 bool hasBaseOrIndexReg() const {
240241 Disp = CurDAG->getTargetExternalSymbol(AM.ES, MVT::i32, AM.SymbolFlags);
241242 else if (AM.JT != -1)
242243 Disp = CurDAG->getTargetJumpTable(AM.JT, MVT::i32, AM.SymbolFlags);
244 else if (AM.BlockAddr)
245 Disp = CurDAG->getBlockAddress(AM.BlockAddr, DebugLoc()/*MVT::i32*/,
246 true /*AM.SymbolFlags*/);
243247 else
244248 Disp = CurDAG->getTargetConstant(AM.Disp, MVT::i32);
245249
759763 } else if (ExternalSymbolSDNode *S = dyn_cast(N0)) {
760764 AM.ES = S->getSymbol();
761765 AM.SymbolFlags = S->getTargetFlags();
762 } else {
763 JumpTableSDNode *J = cast(N0);
766 } else if (JumpTableSDNode *J = dyn_cast(N0)) {
764767 AM.JT = J->getIndex();
765768 AM.SymbolFlags = J->getTargetFlags();
769 } else {
770 AM.BlockAddr = cast(N0)->getBlockAddress();
771 //AM.SymbolFlags = cast(N0)->getTargetFlags();
766772 }
767773
768774 if (N.getOpcode() == X86ISD::WrapperRIP)
788794 } else if (ExternalSymbolSDNode *S = dyn_cast(N0)) {
789795 AM.ES = S->getSymbol();
790796 AM.SymbolFlags = S->getTargetFlags();
791 } else {
792 JumpTableSDNode *J = cast(N0);
797 } else if (JumpTableSDNode *J = dyn_cast(N0)) {
793798 AM.JT = J->getIndex();
794799 AM.SymbolFlags = J->getTargetFlags();
800 } else {
801 AM.BlockAddr = cast(N0)->getBlockAddress();
802 //AM.SymbolFlags = cast(N0)->getTargetFlags();
795803 }
796804 return false;
797805 }
0 ; RUN: llc < %s
1 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-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
2 target triple = "x86_64-apple-darwin10.0"
3
4 define i8 @test1() nounwind ssp {
5 entry:
6 %0 = select i1 undef, i8* blockaddress(@test1, %bb), i8* blockaddress(@test1, %bb6) ; [#uses=1]
7 indirectbr i8* %0, [label %bb, label %bb6]
8
9 bb: ; preds = %entry
10 ret i8 1
11
12 bb6: ; preds = %entry
13 ret i8 2
14 }
15