[llvm-commits] [llvm] r140697 - in /llvm/trunk: lib/Target/PTX/ lib/Target/PTX/InstPrinter/ lib/Target/PTX/MCTargetDesc/ test/CodeGen/PTX/

James Molloy james.molloy at arm.com
Thu Sep 29 06:18:21 PDT 2011


Hi Justin,

 

A heads up from our internal build farm:

 

         Linking CXX executable ../../bin/llvm-objdump

 
../../lib/libLLVMPTXAsmPrinter.a(PTXInstPrinter.cpp.o):(.data.rel.ro+0x0):
undefined reference to `llvm::PTX::RegF32RegClass'

 
../../lib/libLLVMPTXAsmPrinter.a(PTXInstPrinter.cpp.o):(.data.rel.ro+0x4):
undefined reference to `llvm::PTX::RegF64RegClass'

 
../../lib/libLLVMPTXAsmPrinter.a(PTXInstPrinter.cpp.o):(.data.rel.ro+0x8):
undefined reference to `llvm::PTX::RegI16RegClass'

 
../../lib/libLLVMPTXAsmPrinter.a(PTXInstPrinter.cpp.o):(.data.rel.ro+0xc):
undefined reference to `llvm::PTX::RegI32RegClass'

 
../../lib/libLLVMPTXAsmPrinter.a(PTXInstPrinter.cpp.o):(.data.rel.ro+0x10):
undefined reference to `llvm::PTX::RegI64RegClass'

 
../../lib/libLLVMPTXAsmPrinter.a(PTXInstPrinter.cpp.o):(.data.rel.ro+0x14):
undefined reference to `llvm::PTX::RegPredRegClass'

         collect2: ld returned 1 exit status

 

Hope that helps find the problem.

 

Cheers,

 

James

 

From: llvm-commits-bounces at cs.uiuc.edu
[mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Justin Holewinski
Sent: 29 September 2011 13:55
To: Eric Christopher
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: [llvm-commits] [llvm] r140697 - in /llvm/trunk: lib/Target/PTX/
lib/Target/PTX/InstPrinter/ lib/Target/PTX/MCTargetDesc/ test/CodeGen/PTX/

 

On Thu, Sep 29, 2011 at 7:52 AM, Justin Holewinski
<justin.holewinski at gmail.com> wrote:


On Sep 29, 2011 3:22 AM, "Eric Christopher" <echristo at apple.com> wrote:
>
> Hi Justin,
>
> We've had a number of complaints that this broke --enable-shared building,
if you could please fix this we'd appreciate it so I don't have to roll back
all of the commits to ptx from today.

Interesting, ill look into it immediately.

 

Besides Heikki's report, what are the reported errors?  I just tried a
shared build with:

 

../configure --enable-optimized --enable-assertions
--enable-targets=host,ptx --enable-shared

 

and everything seems to build fine.

 

>
> Thanks!
>
> -eric
>
>
> On Sep 28, 2011, at 7:32 AM, Justin Holewinski wrote:
>
> > Author: jholewinski
> > Date: Wed Sep 28 09:32:04 2011
> > New Revision: 140697
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=140697
<http://llvm.org/viewvc/llvm-project?rev=140697&view=rev> &view=rev
> > Log:
> > PTX: MC-ize the PTX back-end (patch 1 of N)
> >
> > Lay some groundwork for converting to MC-based asm printer. This is the
first
> > of probably many patches to bring the back-end back up-to-date with all
of the
> > recent MC changes.
> >
> > Added:
> >    llvm/trunk/lib/Target/PTX/InstPrinter/
> >    llvm/trunk/lib/Target/PTX/InstPrinter/CMakeLists.txt
> >    llvm/trunk/lib/Target/PTX/InstPrinter/Makefile
> >    llvm/trunk/lib/Target/PTX/InstPrinter/PTXInstPrinter.cpp
> >    llvm/trunk/lib/Target/PTX/InstPrinter/PTXInstPrinter.h
> >    llvm/trunk/lib/Target/PTX/PTXAsmPrinter.h
> >    llvm/trunk/lib/Target/PTX/PTXMCInstLower.cpp
> > Modified:
> >    llvm/trunk/lib/Target/PTX/CMakeLists.txt
> >    llvm/trunk/lib/Target/PTX/MCTargetDesc/CMakeLists.txt
> >    llvm/trunk/lib/Target/PTX/MCTargetDesc/PTXMCTargetDesc.cpp
> >    llvm/trunk/lib/Target/PTX/Makefile
> >    llvm/trunk/lib/Target/PTX/PTX.h
> >    llvm/trunk/lib/Target/PTX/PTX.td
> >    llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp
> >    llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp
> >    llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp
> >    llvm/trunk/lib/Target/PTX/PTXInstrFormats.td
> >    llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp
> >    llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp
> >    llvm/trunk/lib/Target/PTX/PTXMachineFunctionInfo.h
> >    llvm/trunk/test/CodeGen/PTX/add.ll
> >    llvm/trunk/test/CodeGen/PTX/mov.ll
> >    llvm/trunk/test/CodeGen/PTX/mul.ll
> >    llvm/trunk/test/CodeGen/PTX/sub.ll
> >
> > Modified: llvm/trunk/lib/Target/PTX/CMakeLists.txt
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/CMakeLists.txt
?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/CMakeLists.tx
t?rev=140697&r1=140696&r2=140697&view=diff> &r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/CMakeLists.txt (original)
> > +++ llvm/trunk/lib/Target/PTX/CMakeLists.txt Wed Sep 28 09:32:04 2011
> > @@ -14,6 +14,7 @@
> >   PTXInstrInfo.cpp
> >   PTXFrameLowering.cpp
> >   PTXMCAsmStreamer.cpp
> > +  PTXMCInstLower.cpp
> >   PTXMFInfoExtract.cpp
> >   PTXParamManager.cpp
> >   PTXRegAlloc.cpp
> > @@ -37,4 +38,6 @@
> >   )
> >
> > add_subdirectory(TargetInfo)
> > +add_subdirectory(InstPrinter)
> > add_subdirectory(MCTargetDesc)
> > +
> >
> > Added: llvm/trunk/lib/Target/PTX/InstPrinter/CMakeLists.txt
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/InstPrinter/CM
akeLists.txt?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/InstPrinter/C
MakeLists.txt?rev=140697&view=auto> &view=auto
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/InstPrinter/CMakeLists.txt (added)
> > +++ llvm/trunk/lib/Target/PTX/InstPrinter/CMakeLists.txt Wed Sep 28
09:32:04 2011
> > @@ -0,0 +1,13 @@
> > +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/.. )
> > +
> > +add_llvm_library(LLVMPTXAsmPrinter
> > +  PTXInstPrinter.cpp
> > +  )
> > +
> > +add_dependencies(LLVMPTXAsmPrinter PTXCommonTableGen)
> > +
> > +add_llvm_library_dependencies(LLVMPTXAsmPrinter
> > +  LLVMMC
> > +  LLVMSupport
> > +  )
> > +
> >
> > Added: llvm/trunk/lib/Target/PTX/InstPrinter/Makefile
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/InstPrinter/Ma
kefile?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/InstPrinter/M
akefile?rev=140697&view=auto> &view=auto
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/InstPrinter/Makefile (added)
> > +++ llvm/trunk/lib/Target/PTX/InstPrinter/Makefile Wed Sep 28 09:32:04
2011
> > @@ -0,0 +1,16 @@
> > +##===- lib/Target/PTX/AsmPrinter/Makefile ------------------*- Makefile
-*-===##
> > +#
> > +#
The LLVM Compiler Infrastructure
> > +#
> > +# This file is distributed under the University of Illinois Open Source
> > +# License. See LICENSE.TXT for details.
> > +#
> >
+##===----------------------------------------------------------------------
===##
> > +LEVEL = ../../../..
> > +LIBRARYNAME = LLVMPTXAsmPrinter
> > +
> > +# Hack: we need to include 'main' ptx target directory to grab private
headers
> > +CPP.Flags += -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
> > +
> > +include $(LEVEL)/Makefile.common
> > +
> >
> > Added: llvm/trunk/lib/Target/PTX/InstPrinter/PTXInstPrinter.cpp
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/InstPrinter/PT
XInstPrinter.cpp?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/InstPrinter/P
TXInstPrinter.cpp?rev=140697&view=auto> &view=auto
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/InstPrinter/PTXInstPrinter.cpp (added)
> > +++ llvm/trunk/lib/Target/PTX/InstPrinter/PTXInstPrinter.cpp Wed Sep 28
09:32:04 2011
> > @@ -0,0 +1,149 @@
> > +//===-- PTXInstPrinter.cpp - Convert PTX MCInst to assembly syntax
--------===//
> > +//
> > +//                     The LLVM Compiler Infrastructure
> > +//
> > +// This file is distributed under the University of Illinois Open
Source
> > +// License. See LICENSE.TXT for details.
> > +//
> >
+//===----------------------------------------------------------------------
===//
> > +//
> > +// This class prints a PTX MCInst to a .ptx file.
> > +//
> >
+//===----------------------------------------------------------------------
===//
> > +
> > +#define DEBUG_TYPE "asm-printer"
> > +#include "PTXInstPrinter.h"
> > +#include "PTXMachineFunctionInfo.h"
> > +#include "llvm/MC/MCAsmInfo.h"
> > +#include "llvm/MC/MCExpr.h"
> > +#include "llvm/MC/MCInst.h"
> > +#include "llvm/MC/MCSymbol.h"
> > +#include "llvm/ADT/StringExtras.h"
> > +#include "llvm/Support/raw_ostream.h"
> > +using namespace llvm;
> > +
> > +#define GET_INSTRUCTION_NAME
> > +#include "PTXGenAsmWriter.inc"
> > +
> > +PTXInstPrinter::PTXInstPrinter(const MCAsmInfo &MAI,
> > +                               const MCSubtargetInfo &STI) :
> > +  MCInstPrinter(MAI) {
> > +  // Initialize the set of available features.
> > +  setAvailableFeatures(STI.getFeatureBits());
> > +}
> > +
> > +StringRef PTXInstPrinter::getOpcodeName(unsigned Opcode) const {
> > +  return getInstructionName(Opcode);
> > +}
> > +
> > +void PTXInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo)
const {
> > +  OS << getRegisterName(RegNo);
> > +}
> > +
> > +void PTXInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
> > +                               StringRef Annot) {
> > +  printPredicate(MI, O);
> > +  switch (MI->getOpcode()) {
> > +  default:
> > +    printInstruction(MI, O);
> > +    break;
> > +  case PTX::CALL:
> > +    printCall(MI, O);
> > +  }
> > +  O << ";";
> > +  printAnnotation(O, Annot);
> > +}
> > +
> > +void PTXInstPrinter::printPredicate(const MCInst *MI, raw_ostream &O) {
> > +  // The last two operands are the predicate operands
> > +  int RegIndex;
> > +  int OpIndex;
> > +
> > +  if (MI->getOpcode() == PTX::CALL) {
> > +    RegIndex = 0;
> > +    OpIndex  = 1;
> > +  } else {
> > +    RegIndex = MI->getNumOperands()-2;
> > +    OpIndex = MI->getNumOperands()-1;
> > +  }
> > +
> > +  int PredOp = MI->getOperand(OpIndex).getImm();
> > +  if (PredOp != PTX::PRED_NONE) {
> > +    if (PredOp == PTX::PRED_NEGATE) {
> > +      O << '!';
> > +    } else {
> > +      O << '@';
> > +    }
> > +    printOperand(MI, RegIndex, O);
> > +  }
> > +}
> > +
> > +void PTXInstPrinter::printCall(const MCInst *MI, raw_ostream &O) {
> > +  O << "\tcall.uni\t";
> > +  // The first two operands are the predicate slot
> > +  unsigned Index = 2;
> > +  unsigned NumRets = MI->getOperand(Index++).getImm();
> > +  for (unsigned i = 0; i < NumRets; ++i) {
> > +    if (i == 0) {
> > +      O << "(";
> > +    } else {
> > +      O << ", ";
> > +    }
> > +    printOperand(MI, Index++, O);
> > +  }
> > +
> > +  if (NumRets > 0) {
> > +    O << "), ";
> > +  }
> > +
> > +  O << *(MI->getOperand(Index++).getExpr()) << ", (";
> > +
> > +  unsigned NumArgs = MI->getOperand(Index++).getImm();
> > +  for (unsigned i = 0; i < NumArgs; ++i) {
> > +    printOperand(MI, Index++, O);
> > +    if (i < NumArgs-1) {
> > +      O << ", ";
> > +    }
> > +  }
> > +
> > +  O << ")";
> > +}
> > +
> > +void PTXInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
> > +                                  raw_ostream &O) {
> > +  const MCOperand &Op = MI->getOperand(OpNo);
> > +  if (Op.isImm()) {
> > +    O << Op.getImm();
> > +  } else if (Op.isFPImm()) {
> > +    double Imm = Op.getFPImm();
> > +    APFloat FPImm(Imm);
> > +    APInt FPIntImm = FPImm.bitcastToAPInt();
> > +    O << "0D";
> > +    // PTX requires us to output the full 64 bits, even if the number
is zero
> > +    if (FPIntImm.getZExtValue() > 0) {
> > +      O << FPIntImm.toString(16, false);
> > +    } else {
> > +      O << "0000000000000000";
> > +    }
> > +  } else {
> > +    assert(Op.isExpr() && "unknown operand kind in printOperand");
> > +    const MCExpr *Expr = Op.getExpr();
> > +    if (const MCSymbolRefExpr *SymRefExpr =
dyn_cast<MCSymbolRefExpr>(Expr)) {
> > +      const MCSymbol &Sym = SymRefExpr->getSymbol();
> > +      O << Sym.getName();
> > +    } else {
> > +      O << *Op.getExpr();
> > +    }
> > +  }
> > +}
> > +
> > +void PTXInstPrinter::printMemOperand(const MCInst *MI, unsigned OpNo,
> > +                                     raw_ostream &O) {
> > +  printOperand(MI, OpNo, O);
> > +  if (MI->getOperand(OpNo+1).isImm() && MI->getOperand(OpNo+1).getImm()
== 0)
> > +    return; // don't print "+0"
> > +  O << "+";
> > +  printOperand(MI, OpNo+1, O);
> > +}
> > +
> > +
> >
> > Added: llvm/trunk/lib/Target/PTX/InstPrinter/PTXInstPrinter.h
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/InstPrinter/PT
XInstPrinter.h?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/InstPrinter/P
TXInstPrinter.h?rev=140697&view=auto> &view=auto
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/InstPrinter/PTXInstPrinter.h (added)
> > +++ llvm/trunk/lib/Target/PTX/InstPrinter/PTXInstPrinter.h Wed Sep 28
09:32:04 2011
> > @@ -0,0 +1,46 @@
> > +//===-- PTXInstPrinter.h - Convert PTX MCInst to assembly syntax
----------===//
> > +//
> > +//                     The LLVM Compiler Infrastructure
> > +//
> > +// This file is distributed under the University of Illinois Open
Source
> > +// License. See LICENSE.TXT for details.
> > +//
> >
+//===----------------------------------------------------------------------
===//
> > +//
> > +// This class prints n PTX MCInst to a .ptx file.
> > +//
> >
+//===----------------------------------------------------------------------
===//
> > +
> > +#ifndef PTXINSTPRINTER_H
> > +#define PTXINSTPRINTER_H
> > +
> > +#include "llvm/MC/MCInstPrinter.h"
> > +#include "llvm/MC/MCSubtargetInfo.h"
> > +
> > +namespace llvm {
> > +
> > +class MCOperand;
> > +
> > +class PTXInstPrinter : public MCInstPrinter {
> > +public:
> > +  PTXInstPrinter(const MCAsmInfo &MAI, const MCSubtargetInfo &STI);
> > +
> > +  virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef
Annot);
> > +  virtual StringRef getOpcodeName(unsigned Opcode) const;
> > +  virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
> > +
> > +  static const char *getInstructionName(unsigned Opcode);
> > +
> > +  // Autogenerated by tblgen.
> > +  void printInstruction(const MCInst *MI, raw_ostream &O);
> > +  static const char *getRegisterName(unsigned RegNo);
> > +
> > +  void printPredicate(const MCInst *MI, raw_ostream &O);
> > +  void printCall(const MCInst *MI, raw_ostream &O);
> > +  void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
> > +  void printMemOperand(const MCInst *MI, unsigned OpNo, raw_ostream
&O);
> > +};
> > +}
> > +
> > +#endif
> > +
> >
> > Modified: llvm/trunk/lib/Target/PTX/MCTargetDesc/CMakeLists.txt
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/MCTargetDesc/C
MakeLists.txt?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/MCTargetDesc/
CMakeLists.txt?rev=140697&r1=140696&r2=140697&view=diff>
&r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/MCTargetDesc/CMakeLists.txt (original)
> > +++ llvm/trunk/lib/Target/PTX/MCTargetDesc/CMakeLists.txt Wed Sep 28
09:32:04 2011
> > @@ -6,6 +6,7 @@
> > add_llvm_library_dependencies(LLVMPTXDesc
> >   LLVMMC
> >   LLVMPTXInfo
> > +  LLVMPTXAsmPrinter
> >   LLVMSupport
> >   )
> >
> >
> > Modified: llvm/trunk/lib/Target/PTX/MCTargetDesc/PTXMCTargetDesc.cpp
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/MCTargetDesc/P
TXMCTargetDesc.cpp?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/MCTargetDesc/
PTXMCTargetDesc.cpp?rev=140697&r1=140696&r2=140697&view=diff>
&r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/MCTargetDesc/PTXMCTargetDesc.cpp
(original)
> > +++ llvm/trunk/lib/Target/PTX/MCTargetDesc/PTXMCTargetDesc.cpp Wed Sep
28 09:32:04 2011
> > @@ -13,6 +13,7 @@
> >
> > #include "PTXMCTargetDesc.h"
> > #include "PTXMCAsmInfo.h"
> > +#include "InstPrinter/PTXInstPrinter.h"
> > #include "llvm/MC/MCCodeGenInfo.h"
> > #include "llvm/MC/MCInstrInfo.h"
> > #include "llvm/MC/MCRegisterInfo.h"
> > @@ -57,6 +58,15 @@
> >   return X;
> > }
> >
> > +static MCInstPrinter *createPTXMCInstPrinter(const Target &T,
> > +                                             unsigned SyntaxVariant,
> > +                                             const MCAsmInfo &MAI,
> > +                                             const MCSubtargetInfo
&STI) {
> > +  if (SyntaxVariant == 0)
> > +    return new PTXInstPrinter(MAI, STI);
> > +  return 0;
> > +}
> > +
> > extern "C" void LLVMInitializePTXTargetMC() {
> >   // Register the MC asm info.
> >   RegisterMCAsmInfo<PTXMCAsmInfo> X(ThePTX32Target);
> > @@ -79,4 +89,8 @@
> >                                           createPTXMCSubtargetInfo);
> >   TargetRegistry::RegisterMCSubtargetInfo(ThePTX64Target,
> >                                           createPTXMCSubtargetInfo);
> > +
> > +  // Register the MCInstPrinter.
> > +  TargetRegistry::RegisterMCInstPrinter(ThePTX32Target,
createPTXMCInstPrinter);
> > +  TargetRegistry::RegisterMCInstPrinter(ThePTX64Target,
createPTXMCInstPrinter);
> > }
> >
> > Modified: llvm/trunk/lib/Target/PTX/Makefile
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/Makefile?rev=1
40697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/Makefile?rev=
140697&r1=140696&r2=140697&view=diff> &r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/Makefile (original)
> > +++ llvm/trunk/lib/Target/PTX/Makefile Wed Sep 28 09:32:04 2011
> > @@ -18,6 +18,6 @@
> >               PTXGenRegisterInfo.inc \
> >               PTXGenSubtargetInfo.inc
> >
> > -DIRS = TargetInfo MCTargetDesc
> > +DIRS = InstPrinter TargetInfo MCTargetDesc
> >
> > include $(LEVEL)/Makefile.common
> >
> > Modified: llvm/trunk/lib/Target/PTX/PTX.h
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTX.h?rev=1406
97
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTX.h?rev=140
697&r1=140696&r2=140697&view=diff> &r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/PTX.h (original)
> > +++ llvm/trunk/lib/Target/PTX/PTX.h Wed Sep 28 09:32:04 2011
> > @@ -19,6 +19,9 @@
> > #include "llvm/Target/TargetMachine.h"
> >
> > namespace llvm {
> > +  class MachineInstr;
> > +  class MCInst;
> > +  class PTXAsmPrinter;
> >   class PTXTargetMachine;
> >   class FunctionPass;
> >
> > @@ -33,7 +36,8 @@
> >
> >     enum Predicate {
> >       PRED_NORMAL = 0,
> > -      PRED_NEGATE = 1
> > +      PRED_NEGATE = 1,
> > +      PRED_NONE   = 2
> >     };
> >   } // namespace PTX
> >
> > @@ -45,6 +49,9 @@
> >
> >   FunctionPass *createPTXRegisterAllocator();
> >
> > +  void LowerPTXMachineInstrToMCInst(const MachineInstr *MI, MCInst
&OutMI,
> > +                                    PTXAsmPrinter &AP);
> > +
> > } // namespace llvm;
> >
> > #endif // PTX_H
> >
> > Modified: llvm/trunk/lib/Target/PTX/PTX.td
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTX.td?rev=140
697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTX.td?rev=14
0697&r1=140696&r2=140697&view=diff> &r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/PTX.td (original)
> > +++ llvm/trunk/lib/Target/PTX/PTX.td Wed Sep 28 09:32:04 2011
> > @@ -122,9 +122,20 @@
> > def PTXInstrInfo : InstrInfo;
> >
> >
//===----------------------------------------------------------------------=
==//
> > +// Assembly printer
> >
+//===----------------------------------------------------------------------
===//
> > +// PTX uses the MC printer for asm output, so make sure the TableGen
> > +// AsmWriter bits get associated with the correct class.
> > +def PTXAsmWriter : AsmWriter {
> > +  string AsmWriterClassName  = "InstPrinter";
> > +  bit isMCAsmWriter = 1;
> > +}
> > +
> >
+//===----------------------------------------------------------------------
===//
> > // Target Declaration
> >
//===----------------------------------------------------------------------=
==//
> >
> > def PTX : Target {
> >   let InstructionSet = PTXInstrInfo;
> > +  let AssemblyWriters = [PTXAsmWriter];
> > }
> >
> > Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXAsmPrinter.
cpp?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXAsmPrinter
.cpp?rev=140697&r1=140696&r2=140697&view=diff>
&r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp (original)
> > +++ llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp Wed Sep 28 09:32:04 2011
> > @@ -15,6 +15,7 @@
> > #define DEBUG_TYPE "ptx-asm-printer"
> >
> > #include "PTX.h"
> > +#include "PTXAsmPrinter.h"
> > #include "PTXMachineFunctionInfo.h"
> > #include "PTXParamManager.h"
> > #include "PTXRegisterInfo.h"
> > @@ -30,6 +31,8 @@
> > #include "llvm/CodeGen/MachineInstr.h"
> > #include "llvm/CodeGen/MachineRegisterInfo.h"
> > #include "llvm/MC/MCContext.h"
> > +#include "llvm/MC/MCExpr.h"
> > +#include "llvm/MC/MCInst.h"
> > #include "llvm/MC/MCStreamer.h"
> > #include "llvm/MC/MCSymbol.h"
> > #include "llvm/Target/Mangler.h"
> > @@ -44,49 +47,6 @@
> >
> > using namespace llvm;
> >
> > -namespace {
> > -class PTXAsmPrinter : public AsmPrinter {
> > -public:
> > -  explicit PTXAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
> > -    : AsmPrinter(TM, Streamer) {}
> > -
> > -  const char *getPassName() const { return "PTX Assembly Printer"; }
> > -
> > -  bool doFinalization(Module &M);
> > -
> > -  virtual void EmitStartOfAsmFile(Module &M);
> > -
> > -  virtual bool runOnMachineFunction(MachineFunction &MF);
> > -
> > -  virtual void EmitFunctionBodyStart();
> > -  virtual void EmitFunctionBodyEnd() {
OutStreamer.EmitRawText(Twine("}")); }
> > -
> > -  virtual void EmitInstruction(const MachineInstr *MI);
> > -
> > -  void printOperand(const MachineInstr *MI, int opNum, raw_ostream
&OS);
> > -  void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream
&OS,
> > -                       const char *Modifier = 0);
> > -  void printReturnOperand(const MachineInstr *MI, int opNum,
raw_ostream &OS,
> > -                          const char *Modifier = 0);
> > -  void printPredicateOperand(const MachineInstr *MI, raw_ostream &O);
> > -
> > -  void printCall(const MachineInstr *MI, raw_ostream &O);
> > -
> > -  unsigned GetOrCreateSourceID(StringRef FileName,
> > -                               StringRef DirName);
> > -
> > -  // autogen'd.
> > -  void printInstruction(const MachineInstr *MI, raw_ostream &OS);
> > -  static const char *getRegisterName(unsigned RegNo);
> > -
> > -private:
> > -  void EmitVariableDeclaration(const GlobalVariable *gv);
> > -  void EmitFunctionDeclaration();
> > -
> > -  StringMap<unsigned> SourceIdMap;
> > -}; // class PTXAsmPrinter
> > -} // namespace
> > -
> > static const char PARAM_PREFIX[] = "__param_";
> > static const char RETURN_PREFIX[] = "__ret_";
> >
> > @@ -320,7 +280,12 @@
> >   //}
> > }
> >
> > +void PTXAsmPrinter::EmitFunctionBodyEnd() {
> > +  OutStreamer.EmitRawText(Twine("}"));
> > +}
> > +
> > void PTXAsmPrinter::EmitInstruction(const MachineInstr *MI) {
> > +#if 0
> >   std::string str;
> >   str.reserve(64);
> >
> > @@ -388,6 +353,11 @@
> >
> >   StringRef strref = StringRef(str);
> >   OutStreamer.EmitRawText(strref);
> > +#endif
> > +
> > +  MCInst TmpInst;
> > +  LowerPTXMachineInstrToMCInst(MI, TmpInst, *this);
> > +  OutStreamer.EmitInstruction(TmpInst);
> > }
> >
> > void PTXAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
> > @@ -737,10 +707,57 @@
> >   return SrcId;
> > }
> >
> > -#include "PTXGenAsmWriter.inc"
> > +MCOperand PTXAsmPrinter::GetSymbolRef(const MachineOperand &MO,
> > +                                      const MCSymbol *Symbol) {
> > +  const MCExpr *Expr;
> > +  Expr = MCSymbolRefExpr::Create(Symbol, MCSymbolRefExpr::VK_None,
OutContext);
> > +  return MCOperand::CreateExpr(Expr);
> > +}
> > +
> > +bool PTXAsmPrinter::lowerOperand(const MachineOperand &MO, MCOperand
&MCOp) {
> > +  const PTXMachineFunctionInfo *MFI =
MF->getInfo<PTXMachineFunctionInfo>();
> > +  const MCExpr *Expr;
> > +  const char *RegSymbolName;
> > +  switch (MO.getType()) {
> > +  default:
> > +    llvm_unreachable("Unknown operand type");
> > +  case MachineOperand::MO_Register:
> > +    // We create register operands as symbols, since the PTXInstPrinter
class
> > +    // has no way to map virtual registers back to a name without some
ugly
> > +    // hacks.
> > +    // FIXME: Figure out a better way to handle virtual register
naming.
> > +    RegSymbolName = MFI->getRegisterName(MO.getReg());
> > +    Expr = MCSymbolRefExpr::Create(RegSymbolName,
MCSymbolRefExpr::VK_None,
> > +                                   OutContext);
> > +    MCOp = MCOperand::CreateExpr(Expr);
> > +    break;
> > +  case MachineOperand::MO_Immediate:
> > +    MCOp = MCOperand::CreateImm(MO.getImm());
> > +    break;
> > +  case MachineOperand::MO_MachineBasicBlock:
> > +    MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
> > +                                 MO.getMBB()->getSymbol(),
OutContext));
> > +    break;
> > +  case MachineOperand::MO_GlobalAddress:
> > +    MCOp = GetSymbolRef(MO, Mang->getSymbol(MO.getGlobal()));
> > +    break;
> > +  case MachineOperand::MO_ExternalSymbol:
> > +    MCOp = GetSymbolRef(MO,
GetExternalSymbolSymbol(MO.getSymbolName()));
> > +    break;
> > +  case MachineOperand::MO_FPImmediate:
> > +    APFloat Val = MO.getFPImm()->getValueAPF();
> > +    bool ignored;
> > +    Val.convert(APFloat::IEEEdouble, APFloat::rmTowardZero, &ignored);
> > +    MCOp = MCOperand::CreateFPImm(Val.convertToDouble());
> > +    break;
> > +  }
> > +
> > +  return true;
> > +}
> >
> > // Force static initialization.
> > extern "C" void LLVMInitializePTXAsmPrinter() {
> >   RegisterAsmPrinter<PTXAsmPrinter> X(ThePTX32Target);
> >   RegisterAsmPrinter<PTXAsmPrinter> Y(ThePTX64Target);
> > }
> > +
> >
> > Added: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.h
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXAsmPrinter.
h?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXAsmPrinter
.h?rev=140697&view=auto> &view=auto
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/PTXAsmPrinter.h (added)
> > +++ llvm/trunk/lib/Target/PTX/PTXAsmPrinter.h Wed Sep 28 09:32:04 2011
> > @@ -0,0 +1,73 @@
> > +//===-- PTXAsmPrinter.h - Print machine code to a PTX file
----------------===//
> > +//
> > +//                     The LLVM Compiler Infrastructure
> > +//
> > +// This file is distributed under the University of Illinois Open
Source
> > +// License. See LICENSE.TXT for details.
> > +//
> >
+//===----------------------------------------------------------------------
===//
> > +//
> > +// PTX Assembly printer class.
> > +//
> >
+//===----------------------------------------------------------------------
===//
> > +
> > +#ifndef PTXASMPRINTER_H
> > +#define PTXASMPRINTER_H
> > +
> > +#include "PTX.h"
> > +#include "PTXTargetMachine.h"
> > +#include "llvm/ADT/StringMap.h"
> > +#include "llvm/CodeGen/AsmPrinter.h"
> > +#include "llvm/Support/Compiler.h"
> > +
> > +namespace llvm {
> > +
> > +class MCOperand;
> > +
> > +class LLVM_LIBRARY_VISIBILITY PTXAsmPrinter : public AsmPrinter {
> > +public:
> > +  explicit PTXAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
> > +    : AsmPrinter(TM, Streamer) {}
> > +
> > +  const char *getPassName() const { return "PTX Assembly Printer"; }
> > +
> > +  bool doFinalization(Module &M);
> > +
> > +  virtual void EmitStartOfAsmFile(Module &M);
> > +
> > +  virtual bool runOnMachineFunction(MachineFunction &MF);
> > +
> > +  virtual void EmitFunctionBodyStart();
> > +  virtual void EmitFunctionBodyEnd();
> > +
> > +  virtual void EmitInstruction(const MachineInstr *MI);
> > +
> > +  void printOperand(const MachineInstr *MI, int opNum, raw_ostream
&OS);
> > +  void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream
&OS,
> > +                       const char *Modifier = 0);
> > +  void printReturnOperand(const MachineInstr *MI, int opNum,
raw_ostream &OS,
> > +                          const char *Modifier = 0);
> > +  void printPredicateOperand(const MachineInstr *MI, raw_ostream &O);
> > +
> > +  void printCall(const MachineInstr *MI, raw_ostream &O);
> > +
> > +  unsigned GetOrCreateSourceID(StringRef FileName,
> > +                               StringRef DirName);
> > +
> > +  MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol
*Symbol);
> > +  bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
> > +
> > +  // autogen'd.
> > +  void printInstruction(const MachineInstr *MI, raw_ostream &OS);
> > +  static const char *getRegisterName(unsigned RegNo);
> > +
> > +private:
> > +  void EmitVariableDeclaration(const GlobalVariable *gv);
> > +  void EmitFunctionDeclaration();
> > +
> > +  StringMap<unsigned> SourceIdMap;
> > +}; // class PTXAsmPrinter
> > +} // namespace llvm
> > +
> > +#endif
> > +
> >
> > Modified: llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelDAGToDA
G.cpp?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelDAGToD
AG.cpp?rev=140697&r1=140696&r2=140697&view=diff>
&r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp (original)
> > +++ llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp Wed Sep 28 09:32:04
2011
> > @@ -129,7 +129,7 @@
> >     OpCode = PTX::READPARAMF64;
> >
> >   SDValue Pred = CurDAG->getRegister(PTX::NoRegister, MVT::i1);
> > -  SDValue PredOp = CurDAG->getTargetConstant(PTX::PRED_NORMAL,
MVT::i32);
> > +  SDValue PredOp = CurDAG->getTargetConstant(PTX::PRED_NONE, MVT::i32);
> >   DebugLoc dl = Node->getDebugLoc();
> >
> >   SDValue Ops[] = { Index, Pred, PredOp, Chain };
> > @@ -167,7 +167,7 @@
> >     llvm_unreachable("Invalid type in SelectWRITEPARAM");
> >
> >   SDValue Pred = CurDAG->getRegister(PTX::NoRegister, MVT::i1);
> > -  SDValue PredOp = CurDAG->getTargetConstant(PTX::PRED_NORMAL,
MVT::i32);
> > +  SDValue PredOp = CurDAG->getTargetConstant(PTX::PRED_NONE, MVT::i32);
> >   DebugLoc dl = Node->getDebugLoc();
> >
> >   SDValue Ops[] = { Value, Pred, PredOp, Chain };
> >
> > Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelLowerin
g.cpp?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelLoweri
ng.cpp?rev=140697&r1=140696&r2=140697&view=diff>
&r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp (original)
> > +++ llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Wed Sep 28 09:32:04
2011
> > @@ -393,8 +393,8 @@
> >          "Calls are not handled for the target device");
> >
> >   std::vector<SDValue> Ops;
> > -  // The layout of the ops will be [Chain, Ins, Callee, Outs]
> > -  Ops.resize(Outs.size() + Ins.size() + 2);
> > +  // The layout of the ops will be [Chain, #Ins, Ins, Callee, #Outs,
Outs]
> > +  Ops.resize(Outs.size() + Ins.size() + 4);
> >
> >   Ops[0] = Chain;
> >
> > @@ -403,11 +403,12 @@
> >   assert(cast<Function>(GV)->getCallingConv() == CallingConv::PTX_Device
&&
> >          "PTX function calls must be to PTX device functions");
> >   Callee = DAG.getTargetGlobalAddress(GV, dl, getPointerTy());
> > -  Ops[Ins.size()+1] = Callee;
> > +  Ops[Ins.size()+2] = Callee;
> >
> >   // Generate STORE_PARAM nodes for each function argument.  In PTX,
function
> >   // arguments are explicitly stored into .param variables and passed as
> >   // arguments. There is no register/stack-based calling convention in
PTX.
> > +  Ops[Ins.size()+3] = DAG.getTargetConstant(OutVals.size(), MVT::i32);
> >   for (unsigned i = 0; i != OutVals.size(); ++i) {
> >     unsigned Size = OutVals[i].getValueType().getSizeInBits();
> >     unsigned Param = PM.addLocalParam(Size);
> > @@ -416,19 +417,20 @@
> >                                                      MVT::Other);
> >     Chain = DAG.getNode(PTXISD::STORE_PARAM, dl, MVT::Other, Chain,
> >                         ParamValue, OutVals[i]);
> > -    Ops[i+Ins.size()+2] = ParamValue;
> > +    Ops[i+Ins.size()+4] = ParamValue;
> >   }
> >
> >   std::vector<SDValue> InParams;
> >
> >   // Generate list of .param variables to hold the return value(s).
> > +  Ops[1] = DAG.getTargetConstant(Ins.size(), MVT::i32);
> >   for (unsigned i = 0; i < Ins.size(); ++i) {
> >     unsigned Size = Ins[i].VT.getStoreSizeInBits();
> >     unsigned Param = PM.addLocalParam(Size);
> >     const std::string &ParamName = PM.getParamName(Param);
> >     SDValue ParamValue = DAG.getTargetExternalSymbol(ParamName.c_str(),
> >                                                      MVT::Other);
> > -    Ops[i+1] = ParamValue;
> > +    Ops[i+2] = ParamValue;
> >     InParams.push_back(ParamValue);
> >   }
> >
> >
> > Modified: llvm/trunk/lib/Target/PTX/PTXInstrFormats.td
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrFormat
s.td?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrForma
ts.td?rev=140697&r1=140696&r2=140697&view=diff>
&r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/PTXInstrFormats.td (original)
> > +++ llvm/trunk/lib/Target/PTX/PTXInstrFormats.td Wed Sep 28 09:32:04
2011
> > @@ -7,10 +7,10 @@
> > //
> >
//===----------------------------------------------------------------------=
==//
> >
> > -// PTX Predicate operand, default to (0, 0) = (zero-reg, always).
> > +// PTX Predicate operand, default to (0, 0) = (zero-reg, none).
> > // Leave PrintMethod empty; predicate printing is defined elsewhere.
> > def pred : PredicateOperand<OtherVT, (ops RegPred, i32imm),
> > -                                     (ops (i1 zero_reg), (i32 0))>;
> > +                                     (ops (i1 zero_reg), (i32 2))>;
> >
> > let Namespace = "PTX" in {
> >   class InstPTX<dag oops, dag iops, string asmstr, list<dag> pattern>
> >
> > Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.c
pp?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.
cpp?rev=140697&r1=140696&r2=140697&view=diff> &r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp (original)
> > +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp Wed Sep 28 09:32:04 2011
> > @@ -167,7 +167,7 @@
> >     return false;
> >
> >   Pred.push_back(MO);
> > -  Pred.push_back(MachineOperand::CreateImm(PTX::PRED_NORMAL));
> > +  Pred.push_back(MachineOperand::CreateImm(PTX::PRED_NONE));
> >   return true;
> > }
> >
> > @@ -283,7 +283,7 @@
> >     BuildMI(&MBB, DL, get(PTX::BRAdp))
> >       .addMBB(TBB).addReg(Cond[0].getReg()).addImm(Cond[1].getImm());
> >     BuildMI(&MBB, DL, get(PTX::BRAd))
> > -      .addMBB(FBB).addReg(PTX::NoRegister).addImm(PTX::PRED_NORMAL);
> > +      .addMBB(FBB).addReg(PTX::NoRegister).addImm(PTX::PRED_NONE);
> >     return 2;
> >   } else if (Cond.size()) {
> >     BuildMI(&MBB, DL, get(PTX::BRAdp))
> > @@ -291,7 +291,7 @@
> >     return 1;
> >   } else {
> >     BuildMI(&MBB, DL, get(PTX::BRAd))
> > -      .addMBB(TBB).addReg(PTX::NoRegister).addImm(PTX::PRED_NORMAL);
> > +      .addMBB(TBB).addReg(PTX::NoRegister).addImm(PTX::PRED_NONE);
> >     return 1;
> >   }
> > }
> > @@ -319,7 +319,7 @@
> > GetPTXMachineNode(SelectionDAG *DAG, unsigned Opcode,
> >                   DebugLoc dl, EVT VT, SDValue Op1) {
> >   SDValue predReg = DAG->getRegister(PTX::NoRegister, MVT::i1);
> > -  SDValue predOp = DAG->getTargetConstant(PTX::PRED_NORMAL, MVT::i32);
> > +  SDValue predOp = DAG->getTargetConstant(PTX::PRED_NONE, MVT::i32);
> >   SDValue ops[] = { Op1, predReg, predOp };
> >   return DAG->getMachineNode(Opcode, dl, VT, ops, array_lengthof(ops));
> > }
> > @@ -328,7 +328,7 @@
> > GetPTXMachineNode(SelectionDAG *DAG, unsigned Opcode,
> >                   DebugLoc dl, EVT VT, SDValue Op1, SDValue Op2) {
> >   SDValue predReg = DAG->getRegister(PTX::NoRegister, MVT::i1);
> > -  SDValue predOp = DAG->getTargetConstant(PTX::PRED_NORMAL, MVT::i32);
> > +  SDValue predOp = DAG->getTargetConstant(PTX::PRED_NONE, MVT::i32);
> >   SDValue ops[] = { Op1, Op2, predReg, predOp };
> >   return DAG->getMachineNode(Opcode, dl, VT, ops, array_lengthof(ops));
> > }
> > @@ -336,7 +336,7 @@
> > void PTXInstrInfo::AddDefaultPredicate(MachineInstr *MI) {
> >   if (MI->findFirstPredOperandIdx() == -1) {
> >     MI->addOperand(MachineOperand::CreateReg(PTX::NoRegister,
/*IsDef=*/false));
> > -    MI->addOperand(MachineOperand::CreateImm(PTX::PRED_NORMAL));
> > +    MI->addOperand(MachineOperand::CreateImm(PTX::PRED_NONE));
> >   }
> > }
> >
> >
> > Modified: llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXMCAsmStream
er.cpp?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXMCAsmStrea
mer.cpp?rev=140697&r1=140696&r2=140697&view=diff>
&r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp (original)
> > +++ llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp Wed Sep 28 09:32:04
2011
> > @@ -499,7 +499,7 @@
> > void PTXMCAsmStreamer::AddEncodingComment(const MCInst &Inst) {}
> >
> > void PTXMCAsmStreamer::EmitInstruction(const MCInst &Inst) {
> > -  assert(getCurrentSection() && "Cannot emit contents before setting
section!");
> > +//assert(getCurrentSection() && "Cannot emit contents before setting
section!");
> >
> >   // Show the encoding in a comment if we have a code emitter.
> >   if (Emitter)
> >
> > Added: llvm/trunk/lib/Target/PTX/PTXMCInstLower.cpp
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXMCInstLower
.cpp?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXMCInstLowe
r.cpp?rev=140697&view=auto> &view=auto
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/PTXMCInstLower.cpp (added)
> > +++ llvm/trunk/lib/Target/PTX/PTXMCInstLower.cpp Wed Sep 28 09:32:04
2011
> > @@ -0,0 +1,33 @@
> > +//===-- PTXMCInstLower.cpp - Convert PTX MachineInstr to an MCInst
--------===//
> > +//
> > +//                     The LLVM Compiler Infrastructure
> > +//
> > +// This file is distributed under the University of Illinois Open
Source
> > +// License. See LICENSE.TXT for details.
> > +//
> >
+//===----------------------------------------------------------------------
===//
> > +//
> > +// This file contains code to lower PTX MachineInstrs to their
corresponding
> > +// MCInst records.
> > +//
> >
+//===----------------------------------------------------------------------
===//
> > +
> > +#include "PTX.h"
> > +#include "PTXAsmPrinter.h"
> > +#include "llvm/Constants.h"
> > +#include "llvm/CodeGen/MachineBasicBlock.h"
> > +#include "llvm/MC/MCExpr.h"
> > +#include "llvm/MC/MCInst.h"
> > +#include "llvm/Target/Mangler.h"
> > +
> > +void llvm::LowerPTXMachineInstrToMCInst(const MachineInstr *MI, MCInst
&OutMI,
> > +                                        PTXAsmPrinter &AP) {
> > +  OutMI.setOpcode(MI->getOpcode());
> > +  for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
> > +    const MachineOperand &MO = MI->getOperand(i);
> > +    MCOperand MCOp;
> > +    if (AP.lowerOperand(MO, MCOp))
> > +      OutMI.addOperand(MCOp);
> > +  }
> > +}
> > +
> >
> > Modified: llvm/trunk/lib/Target/PTX/PTXMachineFunctionInfo.h
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXMachineFunc
tionInfo.h?rev=140697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXMachineFun
ctionInfo.h?rev=140697&r1=140696&r2=140697&view=diff>
&r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/lib/Target/PTX/PTXMachineFunctionInfo.h (original)
> > +++ llvm/trunk/lib/Target/PTX/PTXMachineFunctionInfo.h Wed Sep 28
09:32:04 2011
> > @@ -128,9 +128,9 @@
> >
> >   /// getRegisterName - Returns the name of the specified virtual
register. This
> >   /// name is used during PTX emission.
> > -  std::string getRegisterName(unsigned Reg) const {
> > +  const char *getRegisterName(unsigned Reg) const {
> >     if (RegNames.count(Reg))
> > -      return RegNames.lookup(Reg);
> > +      return RegNames.find(Reg)->second.c_str();
> >     else if (Reg == PTX::NoRegister)
> >       return "%noreg";
> >     else
> >
> > Modified: llvm/trunk/test/CodeGen/PTX/add.ll
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/add.ll?rev=1
40697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/add.ll?rev=
140697&r1=140696&r2=140697&view=diff> &r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/test/CodeGen/PTX/add.ll (original)
> > +++ llvm/trunk/test/CodeGen/PTX/add.ll Wed Sep 28 09:32:04 2011
> > @@ -57,7 +57,7 @@
> > }
> >
> > define ptx_device float @t2_f32(float %x) {
> > -; CHECK: add.rn.f32 %ret{{[0-9]+}}, %f{{[0-9]+}}, 0F3F800000;
> > +; CHECK: add.rn.f32 %ret{{[0-9]+}}, %f{{[0-9]+}}, 0D3FF0000000000000;
> > ; CHECK: ret;
> >   %z = fadd float %x, 1.0
> >   ret float %z
> >
> > Modified: llvm/trunk/test/CodeGen/PTX/mov.ll
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/mov.ll?rev=1
40697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/mov.ll?rev=
140697&r1=140696&r2=140697&view=diff> &r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/test/CodeGen/PTX/mov.ll (original)
> > +++ llvm/trunk/test/CodeGen/PTX/mov.ll Wed Sep 28 09:32:04 2011
> > @@ -19,7 +19,7 @@
> > }
> >
> > define ptx_device float @t1_f32() {
> > -; CHECK: mov.f32 %ret{{[0-9]+}}, 0F00000000;
> > +; CHECK: mov.f32 %ret{{[0-9]+}}, 0D0000000000000000;
> > ; CHECK: ret;
> >       ret float 0.0
> > }
> >
> > Modified: llvm/trunk/test/CodeGen/PTX/mul.ll
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/mul.ll?rev=1
40697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/mul.ll?rev=
140697&r1=140696&r2=140697&view=diff> &r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/test/CodeGen/PTX/mul.ll (original)
> > +++ llvm/trunk/test/CodeGen/PTX/mul.ll Wed Sep 28 09:32:04 2011
> > @@ -25,7 +25,7 @@
> > }
> >
> > define ptx_device float @t2_f32(float %x) {
> > -; CHECK: mul.rn.f32 %ret{{[0-9]+}}, %f{{[0-9]+}}, 0F40A00000;
> > +; CHECK: mul.rn.f32 %ret{{[0-9]+}}, %f{{[0-9]+}}, 0D4014000000000000;
> > ; CHECK: ret;
> >   %z = fmul float %x, 5.0
> >   ret float %z
> >
> > Modified: llvm/trunk/test/CodeGen/PTX/sub.ll
> > URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/sub.ll?rev=1
40697
<http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/sub.ll?rev=
140697&r1=140696&r2=140697&view=diff> &r1=140696&r2=140697&view=diff
> >
============================================================================
==
> > --- llvm/trunk/test/CodeGen/PTX/sub.ll (original)
> > +++ llvm/trunk/test/CodeGen/PTX/sub.ll Wed Sep 28 09:32:04 2011
> > @@ -57,7 +57,7 @@
> > }
> >
> > define ptx_device float @t2_f32(float %x) {
> > -; CHECK: add.rn.f32 %ret{{[0-9]+}}, %f{{[0-9]+}}, 0FBF800000;
> > +; CHECK: add.rn.f32 %ret{{[0-9]+}}, %f{{[0-9]+}}, 0DBFF0000000000000;
> > ; CHECK: ret;
> >   %z = fsub float %x, 1.0
> >   ret float %z
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>





 

-- 

Thanks,

 

Justin Holewinski

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110929/ec29e3bf/attachment.html>


More information about the llvm-commits mailing list