[llvm-commits] [llvm] r140697 - in /llvm/trunk: lib/Target/PTX/ lib/Target/PTX/InstPrinter/ lib/Target/PTX/MCTargetDesc/ test/CodeGen/PTX/
Justin Holewinski
justin.holewinski at gmail.com
Thu Sep 29 10:46:23 PDT 2011
On Thu, Sep 29, 2011 at 1:13 PM, Jim Grosbach <grosbach at apple.com> wrote:
> Hi Justin,
>
> Thanks for migrating this over to MC. Looking good in general. A few,
> mostly minor, comments inline. You're already tracking down the various
> build system issues, so I won't talk much about that. :)
>
Thanks for the helpful comments! I'll try to work the changes into upcoming
commits.
>
> -Jim
>
> 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&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&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/CMakeLists.txt?rev=140697&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/Makefile?rev=140697&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/PTXInstPrinter.cpp?rev=140697&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"
>
> Don't include PTXMachineFunction.h here. That's a layering violation that
> brings in all of the codegen layer into the MC library. This may be what's
> causing some of the build issues, actually. If there are things in there you
> need to access for instruction printing, they should be factored out into
> the MCTargetDesc bits such that they can be shared by CodeGen and MC.
>
Right, I've refactored this in the fix commit.
>
> > +#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;
> > + }
> > +
>
> Could the predicate be first in the operand list even for call
> instructions? It would be nice, though not required obviously, to have the
> access mechanism for the predicate be the same for all instructions.
>
Yes, this was more of an intermediate hack until the rest of the changes go
in that fix this.
>
> > + int PredOp = MI->getOperand(OpIndex).getImm();
> > + if (PredOp != PTX::PRED_NONE) {
>
> Can just early-exit here to avoid the nested conditional.
> if (PredOp == PTX::PRED_NONE)
> return;
>
Very true.
>
> > + if (PredOp == PTX::PRED_NEGATE) {
> > + O << '!';
> > + } else {
> > + O << '@';
> > + }
>
> No need for braces around compound statements that only have a single
> statement inside them.
>
> > + 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 << "), ";
> > + }
>
> This is somewhat awkward with the explicit checking for NumRets > 0 plus
> the "if (i == 0)" inside the loop. Perhaps something like this instead:
> if (NumRets) {
> O << "(";
> printOperand(MI, Index++, O);
> for (unsigned i = 1; i < NumRets - 1; ++i) {
> O << ", ";
> printOperand(MI, Index++, O);
> }
> O << "), ";
> }
>
Sure, that's much cleaner.
>
> > +
> > + 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 << ", ";
> > + }
>
> Braces. Also, checking "if (i < NumArgs-1)" every time through the loop
> isn't good, like the above. Just peel off one iteration to handle specially
> so the loop doesn't have to handle anything but the normal case.
>
Good catch.
>
> > + }
> > +
> > + 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);
>
> Getting the "OpNo+1" multiple times here. Probably worth storing off a
> reference to it and using that:
> MCOperand &Op = MI->getOperand(OpNo+1);
>
> You already know the operand is an immediate, so no need to call the
> generic printOperand() routine which will just check the type again. Just 'O
> << "+" << Op.getImm();' is sufficient and a bit clearer about what's going
> on.
>
Fair enough.
>
> > +}
> > +
> > +
> >
> > Added: llvm/trunk/lib/Target/PTX/InstPrinter/PTXInstPrinter.h
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/InstPrinter/PTXInstPrinter.h?rev=140697&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/CMakeLists.txt?rev=140697&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/PTXMCTargetDesc.cpp?rev=140697&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);
>
> Somewhat nitty, but you only have one syntax variant as I understand it, so
> you could really just assert() that here if you want and always return the
> normal instprinter.
>
This was just a copy from the ARM version. :)
>
> > + 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=140697&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=140697&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
> > };
>
> Consider putting the condition codes for the predicates in a dedicated
> namespace. That way you don't have to have the "PRED_" prefix on each value.
> See ARM for an example of how that looks in practice.
> namespace PTXCC {
> enum Predicate {
> NORMAL = 0,
> …
> };
> }
>
> > } // 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=140697&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&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
>
> Try to avoid "#if 0" constructs. Just nuke it. If it needs brought back in
> some other form, svn has the history, so we're not losing any information.
>
Forgot to remove that one.
>
> > 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) {
>
> Is there ever going to be an operand type for which this routine returns
> 'false'? If not, just having it return the MCOperand by value directly seems
> preferable.
>
Fair enough. This was another direct translation from ARM.
>
> > + 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&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);
> > +
>
> Do all of these prototypes need to stay?
>
>
Probably not. I'm still trying to determine which parts of the old
AsmPrinter can be safely deleted.
> > + 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);
> This one is definitely gone if the non-MC instprinter is gone.
>
> > + 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/PTXISelDAGToDAG.cpp?rev=140697&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 };
> >
>
> OK, but these look unrelated to the MC printer changes?
>
The short answer is that the change was needed to properly print the
predicates in the new InstPrinter with the new handling of (virtual)
registers. Of course, I should have split this off into a previous commit.
>
> > Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp?rev=140697&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);
> > }
> >
>
> Ditto. Not a huge deal, but it's easier to review if changes are kept
> together in related chunks. Same for the InstrFormats and InstrInfo changes.
>
I'll try to be more careful in the future. :)
>
> >
> > Modified: llvm/trunk/lib/Target/PTX/PTXInstrFormats.td
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrFormats.td?rev=140697&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.cpp?rev=140697&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/PTXMCAsmStreamer.cpp?rev=140697&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!");
> >
>
> Why is this different?
>
This one I cannot answer yet. I have not looked into section handling too
much, mainly because PTX assembly files do not have sections.
>
> > // 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&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/PTXMachineFunctionInfo.h?rev=140697&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=140697&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=140697&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=140697&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=140697&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/0d91e3e8/attachment.html>
More information about the llvm-commits
mailing list