llvm.org GIT mirror llvm / 586994a
[x32] Emit callq for CALLpcrel32 Summary: In AT&T annotation for both x86_64 and x32 calls should be printed as callq in assembly. It's only a matter of correct mnemonic, object output is ok. Test Plan: trivial test added Reviewers: nadav, dschuff, craig.topper Subscribers: llvm-commits, zinovy.nis Differential Revision: http://reviews.llvm.org/D5213 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217435 91177308-0d34-0410-b5e6-96231b3b80d8 Pavel Chupin 6 years ago
4 changed file(s) with 34 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
5252 if (TSFlags & X86II::LOCK)
5353 OS << "\tlock\n";
5454
55 // Output CALLpcrel32 as "callq" in 64-bit mode.
56 // In Intel annotation it's always emitted as "call".
57 //
58 // TODO: Probably this hack should be redesigned via InstAlias in
59 // InstrInfo.td as soon as Requires clause is supported properly
60 // for InstAlias.
61 if (MI->getOpcode() == X86::CALLpcrel32 &&
62 (getAvailableFeatures() & X86::Mode64Bit) != 0) {
63 OS << "\tcallq\t";
64 printPCRelImm(MI, 0, OS);
65 }
5566 // Try to print any aliases first.
56 if (!printAliasInstr(MI, OS))
67 else if (!printAliasInstr(MI, OS))
5768 printInstruction(MI, OS);
5869
5970 // Next always print the annotation.
1414 #define LLVM_LIB_TARGET_X86_INSTPRINTER_X86ATTINSTPRINTER_H
1515
1616 #include "llvm/MC/MCInstPrinter.h"
17 #include "llvm/MC/MCSubtargetInfo.h"
1718
1819 namespace llvm {
1920
2223 class X86ATTInstPrinter final : public MCInstPrinter {
2324 public:
2425 X86ATTInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
25 const MCRegisterInfo &MRI)
26 : MCInstPrinter(MAI, MII, MRI) {}
26 const MCRegisterInfo &MRI, const MCSubtargetInfo &STI)
27 : MCInstPrinter(MAI, MII, MRI) {
28 // Initialize the set of available features.
29 setAvailableFeatures(STI.getFeatureBits());
30 }
2731
2832 void printRegName(raw_ostream &OS, unsigned RegNo) const override;
2933 void printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot) override;
376376 const MCRegisterInfo &MRI,
377377 const MCSubtargetInfo &STI) {
378378 if (SyntaxVariant == 0)
379 return new X86ATTInstPrinter(MAI, MII, MRI);
379 return new X86ATTInstPrinter(MAI, MII, MRI, STI);
380380 if (SyntaxVariant == 1)
381381 return new X86IntelInstPrinter(MAI, MII, MRI);
382382 return nullptr;
0 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-pc-linux -verify-machineinstrs | FileCheck %s
1 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-pc-linux-gnux32 -verify-machineinstrs | FileCheck %s
2 ; RUN: llc < %s -mcpu=generic -mtriple=i686-pc-linux -verify-machineinstrs | FileCheck %s -check-prefix=IA32
3
4 ; trivial test for correct call suffix
5
6 define i32 @far() nounwind uwtable {
7 entry:
8 ; CHECK: callq
9 ; IA32: calll
10 tail call void @foo() nounwind
11 ret i32 0
12 }
13
14 declare void @foo()