[llvm] r190598 - Add an instruction deprecation feature to TableGen.
Hal Finkel
hfinkel at anl.gov
Thu Sep 12 07:47:39 PDT 2013
----- Original Message -----
> Wow, thanks for that.
>
> I added a test case and fixed this in 190604.
Thanks for the speedy fix :) -- Some basic PPC use cases committed in r190605.
I think that we might want to add a deprecation message in addition to the subtarget feature. It would be most useful, I think, to have something like this:
, Deprecated<DeprecatedMFTB, "use mfspr instead">;
(so it would print, "warning: deprecated, use mfspr instead").
What do you think?
-Hal
>
> Joey
>
> -----Original Message-----
> From: Hal Finkel [mailto:hfinkel at anl.gov]
> Sent: 12 September 2013 14:59
> To: Joey Gouly
> Cc: llvm-commits at cs.uiuc.edu
> Subject: Re: [llvm] r190598 - Add an instruction deprecation feature
> to TableGen.
>
> ----- Original Message -----
> > Author: joey
> > Date: Thu Sep 12 05:28:05 2013
> > New Revision: 190598
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=190598&view=rev
> > Log:
> > Add an instruction deprecation feature to TableGen.
> >
> > The 'Deprecated' class allows you to specify a SubtargetFeature
> > that
> > the
> > instruction is deprecated on.
>
> Joey,
>
> I don't think this is working quite right... if you run:
>
> llvm-mc -triple armv7 < test/MC/ARM/deprecated-v8.s
>
> then it still prints:
>
> <stdin>:2:1: warning: deprecated
> setend be
>
> shouldn't it do this only for armv8?
>
> Thanks again,
> Hal
>
> >
> > The 'ComplexDeprecationPredicate' class allows you to define a
> > custom
> > predicate that is called to check for deprecation.
> > For example:
> > ComplexDeprecationPredicate<"MCR">
> >
> > would mean you would have to define the following function:
> > bool getMCRDeprecationInfo(MCInst &MI, MCSubtargetInfo &STI,
> > std::string &Info)
> >
> > Which returns 'false' for not deprecated, and 'true' for deprecated
> > and store the warning message in 'Info'.
> >
> > The MCTargetAsmParser constructor was chaned to take an extra
> > argument of
> > the MCInstrInfo class, so out-of-tree targets will need to be
> > changed.
> >
> >
> > Modified:
> > llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
> > llvm/trunk/include/llvm/MC/MCInstrDesc.h
> > llvm/trunk/include/llvm/Support/TargetRegistry.h
> > llvm/trunk/include/llvm/Target/Target.td
> > llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> > llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
> > llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
> > llvm/trunk/lib/Target/ARM/ARMInstrInfo.td
> > llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
> > llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
> > llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
> > llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
> > llvm/trunk/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
> > llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
> > llvm/trunk/test/MC/ARM/deprecated-v8.s
> > llvm/trunk/tools/llvm-mc/llvm-mc.cpp
> > llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
> > llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
> > llvm/trunk/utils/TableGen/CodeGenInstruction.h
> > llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
> >
> > Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
> > +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Thu Sep 12
> > 05:28:05
> > 2013
> > @@ -41,6 +41,7 @@ namespace llvm {
> > class MCAsmInfo;
> > class MCCFIInstruction;
> > class MCContext;
> > + class MCInstrInfo;
> > class MCSection;
> > class MCStreamer;
> > class MCSymbol;
> > @@ -64,6 +65,7 @@ namespace llvm {
> > ///
> > const MCAsmInfo *MAI;
> >
> > + const MCInstrInfo *MII;
> > /// OutContext - This is the context for the output file that
> > we
> > are
> > /// streaming. This owns all of the global MC-related objects
> > for the
> > /// generated translation unit.
> >
> > Modified: llvm/trunk/include/llvm/MC/MCInstrDesc.h
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCInstrDesc.h?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/include/llvm/MC/MCInstrDesc.h (original)
> > +++ llvm/trunk/include/llvm/MC/MCInstrDesc.h Thu Sep 12 05:28:05
> > 2013
> > @@ -17,6 +17,7 @@
> >
> > #include "llvm/MC/MCInst.h"
> > #include "llvm/MC/MCRegisterInfo.h"
> > +#include "llvm/MC/MCSubtargetInfo.h"
> > #include "llvm/Support/DataTypes.h"
> >
> > namespace llvm {
> > @@ -145,6 +146,10 @@ public:
> > const uint16_t *ImplicitUses; // Registers implicitly read by
> > this instr
> > const uint16_t *ImplicitDefs; // Registers implicitly defined
> > by
> > this instr
> > const MCOperandInfo *OpInfo; // 'NumOperands' entries about
> > operands
> > + uint64_t DeprecatedFeatureMask;// Feature bits that this is
> > deprecated on, if any
> > + // A complex method to determine is a certain is deprecated or
> > not, and return
> > + // the reason for deprecation.
> > + bool (*ComplexDeprecationInfo)(MCInst &, MCSubtargetInfo &,
> > std::string &);
> >
> > /// \brief Returns the value of the specific constraint if
> > /// it is set. Returns -1 if it is not set.
> > @@ -158,6 +163,20 @@ public:
> > return -1;
> > }
> >
> > + /// \brief Returns true if a certain instruction is deprecated
> > and
> > if so
> > + /// returns the reason in \p Info.
> > + bool getDeprecatedInfo(MCInst &MI, MCSubtargetInfo &STI,
> > + std::string &Info) const {
> > + if (ComplexDeprecationInfo)
> > + return ComplexDeprecationInfo(MI, STI, Info);
> > + if (DeprecatedFeatureMask != 0) {
> > + // FIXME: it would be nice to include the subtarget feature
> > here.
> > + Info = "deprecated";
> > + return true;
> > + }
> > + return false;
> > + }
> > +
> > /// \brief Return the opcode number for this descriptor.
> > unsigned getOpcode() const {
> > return Opcode;
> >
> > Modified: llvm/trunk/include/llvm/Support/TargetRegistry.h
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetRegistry.h?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/include/llvm/Support/TargetRegistry.h (original)
> > +++ llvm/trunk/include/llvm/Support/TargetRegistry.h Thu Sep 12
> > 05:28:05 2013
> > @@ -108,7 +108,8 @@ namespace llvm {
> > StringRef TT,
> > StringRef CPU);
> > typedef MCTargetAsmParser
> > *(*MCAsmParserCtorTy)(MCSubtargetInfo
> > &STI,
> > - MCAsmParser
> > &P);
> > + MCAsmParser
> > &P,
> > + const
> > MCInstrInfo &MII);
> > typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target
> > &T,
> > const
> > MCSubtargetInfo
> > &STI);
> > typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Target &T,
> > @@ -386,10 +387,11 @@ namespace llvm {
> > /// \param Parser The target independent parser implementation
> > to use for
> > /// parsing and lexing.
> > MCTargetAsmParser *createMCAsmParser(MCSubtargetInfo &STI,
> > - MCAsmParser &Parser)
> > const
> > {
> > + MCAsmParser &Parser,
> > + const MCInstrInfo &MII)
> > const {
> > if (!MCAsmParserCtorFn)
> > return 0;
> > - return MCAsmParserCtorFn(STI, Parser);
> > + return MCAsmParserCtorFn(STI, Parser, MII);
> > }
> >
> > /// createAsmPrinter - Create a target specific assembly
> > printer
> > pass. This
> > @@ -1142,8 +1144,9 @@ namespace llvm {
> > }
> >
> > private:
> > - static MCTargetAsmParser *Allocator(MCSubtargetInfo &STI,
> > MCAsmParser &P) {
> > - return new MCAsmParserImpl(STI, P);
> > + static MCTargetAsmParser *Allocator(MCSubtargetInfo &STI,
> > MCAsmParser &P,
> > + const MCInstrInfo &MII) {
> > + return new MCAsmParserImpl(STI, P, MII);
> > }
> > };
> >
> >
> > Modified: llvm/trunk/include/llvm/Target/Target.td
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/Target.td?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/include/llvm/Target/Target.td (original)
> > +++ llvm/trunk/include/llvm/Target/Target.td Thu Sep 12 05:28:05
> > 2013
> > @@ -1010,6 +1010,17 @@ class SubtargetFeature<string n, string
> > list<SubtargetFeature> Implies = i;
> > }
> >
> > +/// Specifies a Subtarget feature that this instruction is
> > deprecated on.
> > +class Deprecated<SubtargetFeature dep> {
> > + SubtargetFeature DeprecatedFeatureMask = dep;
> > +}
> > +
> > +/// A custom predicate used to determine if an instruction is
> > +/// deprecated or not.
> > +class ComplexDeprecationPredicate<string dep> {
> > + string ComplexDeprecationPredicate = dep;
> > +}
> > +
> > //===----------------------------------------------------------------------===//
> > // Processor chip sets - These values represent each of the chip
> > sets supported
> > // by the scheduler. Each Processor definition requires
> > corresponding
> >
> > Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
> > +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Sep 12
> > 05:28:05 2013
> > @@ -94,7 +94,7 @@ static unsigned getGVAlignmentLog2(const
> >
> > AsmPrinter::AsmPrinter(TargetMachine &tm, MCStreamer &Streamer)
> > : MachineFunctionPass(ID),
> > - TM(tm), MAI(tm.getMCAsmInfo()),
> > + TM(tm), MAI(tm.getMCAsmInfo()), MII(tm.getInstrInfo()),
> > OutContext(Streamer.getContext()),
> > OutStreamer(Streamer),
> > LastMI(0), LastFn(0), Counter(~0U), SetCounter(0) {
> >
> > Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
> > (original)
> > +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp Thu
> > Sep
> > 12 05:28:05 2013
> > @@ -123,7 +123,7 @@ void AsmPrinter::EmitInlineAsm(StringRef
> > TM.getTargetCPU(),
> > TM.getTargetFeatureString()));
> > OwningPtr<MCTargetAsmParser>
> > - TAP(TM.getTarget().createMCAsmParser(*STI, *Parser));
> > + TAP(TM.getTarget().createMCAsmParser(*STI, *Parser, *MII));
> > if (!TAP)
> > report_fatal_error("Inline asm not supported by this streamer
> > because"
> > " we don't have an asm parser for this
> > target\n");
> >
> > Modified:
> > llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
> > (original)
> > +++ llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
> > Thu
> > Sep 12 05:28:05 2013
> > @@ -54,8 +54,9 @@ public:
> > #include "AArch64GenAsmMatcher.inc"
> > };
> >
> > - AArch64AsmParser(MCSubtargetInfo &_STI, MCAsmParser &_Parser)
> > - : MCTargetAsmParser(), STI(_STI), Parser(_Parser) {
> > + AArch64AsmParser(MCSubtargetInfo &_STI, MCAsmParser &_Parser,
> > + const MCInstrInfo &MII)
> > + : MCTargetAsmParser(), STI(_STI), Parser(_Parser) {
> > MCAsmParserExtension::Initialize(_Parser);
> >
> > // Initialize the set of available features.
> >
> > Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original)
> > +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Thu Sep 12 05:28:05
> > 2013
> > @@ -1840,7 +1840,7 @@ defm PLDW : APreLoad<0, 1, "pldw">, Requ
> > defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
> >
> > def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm,
> > NoItinerary,
> > - "setend\t$end", []>, Requires<[IsARM]> {
> > + "setend\t$end", []>, Requires<[IsARM]>,
> > Deprecated<HasV8Ops> {
> > bits<1> end;
> > let Inst{31-10} = 0b1111000100000001000000;
> > let Inst{9} = end;
> > @@ -4772,7 +4772,8 @@ def MCR : MovRCopro<"mcr", 0 /* from ARM
> > (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt,
> > c_imm:$CRn,
> > c_imm:$CRm, imm0_7:$opc2),
> > [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt,
> > imm:$CRn,
> > - imm:$CRm, imm:$opc2)]>;
> > + imm:$CRm, imm:$opc2)]>,
> > + ComplexDeprecationPredicate<"MCR">;
> > def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
> > (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt,
> > c_imm:$CRn,
> > c_imm:$CRm, 0, pred:$p)>;
> >
> > Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
> > +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Thu Sep 12
> > 05:28:05 2013
> > @@ -24,6 +24,7 @@
> > #include "llvm/MC/MCExpr.h"
> > #include "llvm/MC/MCInst.h"
> > #include "llvm/MC/MCInstrDesc.h"
> > +#include "llvm/MC/MCInstrInfo.h"
> > #include "llvm/MC/MCParser/MCAsmLexer.h"
> > #include "llvm/MC/MCParser/MCAsmParser.h"
> > #include "llvm/MC/MCParser/MCParsedAsmOperand.h"
> > @@ -47,6 +48,7 @@ enum VectorLaneTy { NoLanes, AllLanes, I
> > class ARMAsmParser : public MCTargetAsmParser {
> > MCSubtargetInfo &STI;
> > MCAsmParser &Parser;
> > + const MCInstrInfo &MII;
> > const MCRegisterInfo *MRI;
> >
> > // Unwind directives state
> > @@ -232,8 +234,6 @@ class ARMAsmParser : public MCTargetAsmP
> > SmallVectorImpl<MCParsedAsmOperand*>
> > &Operands);
> > bool shouldOmitPredicateOperand(StringRef Mnemonic,
> > SmallVectorImpl<MCParsedAsmOperand*>
> > &Operands);
> > - bool isDeprecated(MCInst &Inst, StringRef &Info);
> > -
> > public:
> > enum ARMMatchResultTy {
> > Match_RequiresITBlock = FIRST_TARGET_MATCH_RESULT_TY,
> > @@ -245,8 +245,9 @@ public:
> >
> > };
> >
> > - ARMAsmParser(MCSubtargetInfo &_STI, MCAsmParser &_Parser)
> > - : MCTargetAsmParser(), STI(_STI), Parser(_Parser), FPReg(-1) {
> > + ARMAsmParser(MCSubtargetInfo &_STI, MCAsmParser &_Parser,
> > + const MCInstrInfo &MII)
> > + : MCTargetAsmParser(), STI(_STI), Parser(_Parser), MII(MII),
> > FPReg(-1) {
> > MCAsmParserExtension::Initialize(_Parser);
> >
> > // Cache the MCRegisterInfo.
> > @@ -4972,14 +4973,6 @@ bool ARMAsmParser::shouldOmitPredicateOp
> > return false;
> > }
> >
> > -bool ARMAsmParser::isDeprecated(MCInst &Inst, StringRef &Info) {
> > - if (hasV8Ops() && Inst.getOpcode() == ARM::SETEND) {
> > - Info = "armv8";
> > - return true;
> > - }
> > - return false;
> > -}
> > -
> > static bool isDataTypeToken(StringRef Tok) {
> > return Tok == ".8" || Tok == ".16" || Tok == ".32" || Tok ==
> > ".64"
> > ||
> > Tok == ".i8" || Tok == ".i16" || Tok == ".i32" || Tok ==
> > ".i64"
> > ||
> > @@ -5296,16 +5289,6 @@ static bool listContainsReg(MCInst &Inst
> > return false;
> > }
> >
> > -// FIXME: We would really prefer to have MCInstrInfo (the wrapper
> > around
> > -// the ARMInsts array) instead. Getting that here requires awkward
> > -// API changes, though. Better way?
> > -namespace llvm {
> > -extern const MCInstrDesc ARMInsts[];
> > -}
> > -static const MCInstrDesc &getInstDesc(unsigned Opcode) {
> > - return ARMInsts[Opcode];
> > -}
> > -
> > // Return true if instruction has the interesting property of
> > being
> > // allowed in IT blocks, but not being predicable.
> > static bool instIsBreakpoint(const MCInst &Inst) {
> > @@ -5320,7 +5303,7 @@ static bool instIsBreakpoint(const MCIns
> > bool ARMAsmParser::
> > validateInstruction(MCInst &Inst,
> > const SmallVectorImpl<MCParsedAsmOperand*>
> > &Operands) {
> > - const MCInstrDesc &MCID = getInstDesc(Inst.getOpcode());
> > + const MCInstrDesc &MCID = MII.get(Inst.getOpcode());
> > SMLoc Loc = Operands[0]->getStartLoc();
> >
> > // Check the IT block state first.
> > @@ -5513,10 +5496,6 @@ validateInstruction(MCInst &Inst,
> > }
> > }
> >
> > - StringRef DepInfo;
> > - if (isDeprecated(Inst, DepInfo))
> > - Warning(Loc, "deprecated on " + DepInfo);
> > -
> > return false;
> > }
> >
> > @@ -7553,7 +7532,7 @@ unsigned ARMAsmParser::checkTargetMatchP
> > // 16-bit thumb arithmetic instructions either require or
> > preclude
> > the 'S'
> > // suffix depending on whether they're in an IT block or not.
> > unsigned Opc = Inst.getOpcode();
> > - const MCInstrDesc &MCID = getInstDesc(Opc);
> > + const MCInstrDesc &MCID = MII.get(Opc);
> > if (MCID.TSFlags & ARMII::ThumbArithFlagSetting) {
> > assert(MCID.hasOptionalDef() &&
> > "optionally flag setting instruction missing optional
> > def
> > operand");
> >
> > Modified:
> > llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
> > (original)
> > +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp Thu
> > Sep 12 05:28:05 2013
> > @@ -26,16 +26,32 @@
> > #include "llvm/Support/ErrorHandling.h"
> > #include "llvm/Support/TargetRegistry.h"
> >
> > +using namespace llvm;
> > +
> > #define GET_REGINFO_MC_DESC
> > #include "ARMGenRegisterInfo.inc"
> >
> > +static bool getMCRDeprecationInfo(MCInst &MI, MCSubtargetInfo
> > &STI,
> > + std::string &Info) {
> > + // Checks for the deprecated CP15ISB encoding:
> > + // mcr pX, #0, rX, c7, c5, #4
> > + if (STI.getFeatureBits() & llvm::ARM::HasV8Ops &&
> > + (MI.getOperand(1).isImm() && MI.getOperand(1).getImm() == 0)
> > &&
> > + (MI.getOperand(3).isImm() && MI.getOperand(3).getImm() == 7)
> > &&
> > + (MI.getOperand(4).isImm() && MI.getOperand(4).getImm() == 5)
> > &&
> > + (MI.getOperand(5).isImm() && MI.getOperand(5).getImm() ==
> > 4))
> > {
> > + Info = "deprecated on armv8";
> > + return true;
> > + }
> > + return false;
> > +}
> > +
> > #define GET_INSTRINFO_MC_DESC
> > #include "ARMGenInstrInfo.inc"
> >
> > #define GET_SUBTARGETINFO_MC_DESC
> > #include "ARMGenSubtargetInfo.inc"
> >
> > -using namespace llvm;
> >
> > std::string ARM_MC::ParseARMTriple(StringRef TT, StringRef CPU) {
> > Triple triple(TT);
> >
> > Modified: llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
> > (original)
> > +++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Thu Sep
> > 12
> > 05:28:05 2013
> > @@ -24,6 +24,10 @@
> >
> > using namespace llvm;
> >
> > +namespace llvm {
> > +class MCInstrInfo;
> > +}
> > +
> > namespace {
> > class MipsAssemblerOptions {
> > public:
> > @@ -201,8 +205,10 @@ class MipsAsmParser : public MCTargetAsm
> > bool processInstruction(MCInst &Inst, SMLoc IDLoc,
> > SmallVectorImpl<MCInst> &Instructions);
> > public:
> > - MipsAsmParser(MCSubtargetInfo &sti, MCAsmParser &parser)
> > - : MCTargetAsmParser(), STI(sti), Parser(parser),
> > hasConsumedDollar(false) {
> > + MipsAsmParser(MCSubtargetInfo &sti, MCAsmParser &parser,
> > + const MCInstrInfo &MII)
> > + : MCTargetAsmParser(), STI(sti), Parser(parser),
> > + hasConsumedDollar(false) {
> > // Initialize the set of available features.
> > setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
> > }
> >
> > Modified: llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
> > (original)
> > +++ llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp Thu
> > Sep
> > 12 05:28:05 2013
> > @@ -218,8 +218,9 @@ class PPCAsmParser : public MCTargetAsmP
> >
> >
> > public:
> > - PPCAsmParser(MCSubtargetInfo &_STI, MCAsmParser &_Parser)
> > - : MCTargetAsmParser(), STI(_STI), Parser(_Parser) {
> > + PPCAsmParser(MCSubtargetInfo &_STI, MCAsmParser &_Parser,
> > + const MCInstrInfo &MII)
> > + : MCTargetAsmParser(), STI(_STI), Parser(_Parser) {
> > // Check for 64-bit vs. 32-bit pointer mode.
> > Triple TheTriple(STI.getTargetTriple());
> > IsPPC64 = (TheTriple.getArch() == Triple::ppc64 ||
> >
> > Modified:
> > llvm/trunk/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
> > (original)
> > +++ llvm/trunk/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
> > Thu
> > Sep 12 05:28:05 2013
> > @@ -327,8 +327,9 @@ private:
> > StringRef Mnemonic);
> >
> > public:
> > - SystemZAsmParser(MCSubtargetInfo &sti, MCAsmParser &parser)
> > - : MCTargetAsmParser(), STI(sti), Parser(parser) {
> > + SystemZAsmParser(MCSubtargetInfo &sti, MCAsmParser &parser,
> > + const MCInstrInfo &MII)
> > + : MCTargetAsmParser(), STI(sti), Parser(parser) {
> > MCAsmParserExtension::Initialize(Parser);
> >
> > // Initialize the set of available features.
> >
> > Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
> > +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Thu Sep 12
> > 05:28:05 2013
> > @@ -556,8 +556,9 @@ private:
> > /// }
> >
> > public:
> > - X86AsmParser(MCSubtargetInfo &sti, MCAsmParser &parser)
> > - : MCTargetAsmParser(), STI(sti), Parser(parser), InstInfo(0) {
> > + X86AsmParser(MCSubtargetInfo &sti, MCAsmParser &parser,
> > + const MCInstrInfo &MII)
> > + : MCTargetAsmParser(), STI(sti), Parser(parser), InstInfo(0)
> > {
> >
> > // Initialize the set of available features.
> > setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
> >
> > Modified: llvm/trunk/test/MC/ARM/deprecated-v8.s
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/deprecated-v8.s?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/test/MC/ARM/deprecated-v8.s (original)
> > +++ llvm/trunk/test/MC/ARM/deprecated-v8.s Thu Sep 12 05:28:05 2013
> > @@ -1,3 +1,5 @@
> > @ RUN: llvm-mc -triple armv8 -show-encoding < %s 2>&1 | FileCheck
> > %s
> > setend be
> > +@ CHECK: warning: deprecated
> > +mcr p8, #0, r5, c7, c5, #4
> > @ CHECK: warning: deprecated on armv8
> >
> > Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
> > +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Thu Sep 12 05:28:05 2013
> > @@ -319,10 +319,10 @@ static int AsLexInput(SourceMgr &SrcMgr,
> >
> > static int AssembleInput(const char *ProgName, const Target
> > *TheTarget,
> > SourceMgr &SrcMgr, MCContext &Ctx,
> > MCStreamer &Str,
> > - MCAsmInfo &MAI, MCSubtargetInfo &STI) {
> > + MCAsmInfo &MAI, MCSubtargetInfo &STI,
> > MCInstrInfo &MCII) {
> > OwningPtr<MCAsmParser> Parser(createMCAsmParser(SrcMgr, Ctx,
> > Str, MAI));
> > - OwningPtr<MCTargetAsmParser>
> > TAP(TheTarget->createMCAsmParser(STI,
> > *Parser));
> > + OwningPtr<MCTargetAsmParser>
> > TAP(TheTarget->createMCAsmParser(STI,
> > *Parser, MCII));
> > if (!TAP) {
> > errs() << ProgName
> > << ": error: this target does not support assembly
> > parsing.\n";
> > @@ -459,7 +459,7 @@ int main(int argc, char **argv) {
> > Res = AsLexInput(SrcMgr, *MAI, Out.get());
> > break;
> > case AC_Assemble:
> > - Res = AssembleInput(ProgName, TheTarget, SrcMgr, Ctx, *Str,
> > *MAI, *STI);
> > + Res = AssembleInput(ProgName, TheTarget, SrcMgr, Ctx, *Str,
> > *MAI, *STI, *MCII);
> > break;
> > case AC_MDisassemble:
> > assert(IP && "Expected assembly output");
> >
> > Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
> > +++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Thu Sep 12
> > 05:28:05 2013
> > @@ -430,6 +430,9 @@ struct MatchableInfo {
> > /// function.
> > std::string ConversionFnKind;
> >
> > + /// If this instruction is deprecated in some form.
> > + bool HasDeprecation;
> > +
> > MatchableInfo(const CodeGenInstruction &CGI)
> > : AsmVariantID(0), TheDef(CGI.TheDef), DefRec(&CGI),
> > AsmString(CGI.AsmString) {
> > @@ -779,6 +782,13 @@ void MatchableInfo::initialize(const Asm
> > if (Record *Reg = AsmOperands[i].SingletonReg)
> > SingletonRegisters.insert(Reg);
> > }
> > +
> > + const RecordVal *DepMask =
> > TheDef->getValue("DeprecatedFeatureMask");
> > + if (!DepMask)
> > + DepMask = TheDef->getValue("ComplexDeprecationPredicate");
> > +
> > + HasDeprecation =
> > + DepMask ?
> > !DepMask->getValue()->getAsUnquotedString().empty()
> > : false;
> > }
> >
> > /// tokenizeAsmString - Tokenize a simplified assembly string.
> > @@ -2743,11 +2753,13 @@ void AsmMatcherEmitter::run(raw_ostream
> >
> > size_t MaxNumOperands = 0;
> > unsigned MaxMnemonicIndex = 0;
> > + bool HasDeprecation = false;
> > for (std::vector<MatchableInfo*>::const_iterator it =
> > Info.Matchables.begin(), ie = Info.Matchables.end();
> > it != ie; ++it) {
> > MatchableInfo &II = **it;
> > MaxNumOperands = std::max(MaxNumOperands,
> > II.AsmOperands.size());
> > + HasDeprecation |= II.HasDeprecation;
> >
> > // Store a pascal-style length byte in the mnemonic.
> > std::string LenMnemonic = char(II.Mnemonic.size()) +
> > II.Mnemonic.str();
> > @@ -3018,6 +3030,14 @@ void AsmMatcherEmitter::run(raw_ostream
> > if (!InsnCleanupFn.empty())
> > OS << " " << InsnCleanupFn << "(Inst);\n";
> >
> > + if (HasDeprecation) {
> > + OS << " std::string Info;\n";
> > + OS << " if
> > (MII.get(Inst.getOpcode()).getDeprecatedInfo(Inst,
> > STI, Info)) {\n";
> > + OS << " SMLoc Loc = ((" << Target.getName() <<
> > "Operand*)Operands[0])->getStartLoc();\n";
> > + OS << " Parser.Warning(Loc, Info, None);\n";
> > + OS << " }\n";
> > + }
> > +
> > OS << " return Match_Success;\n";
> > OS << " }\n\n";
> >
> >
> > Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.cpp?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/utils/TableGen/CodeGenInstruction.cpp (original)
> > +++ llvm/trunk/utils/TableGen/CodeGenInstruction.cpp Thu Sep 12
> > 05:28:05 2013
> > @@ -337,6 +337,20 @@ CodeGenInstruction::CodeGenInstruction(R
> >
> > // Parse the DisableEncoding field.
> > Operands.ProcessDisableEncoding(R->getValueAsString("DisableEncoding"));
> > +
> > + // First check for a ComplexDeprecationPredicate.
> > + if (R->getValue("ComplexDeprecationPredicate")) {
> > + HasComplexDeprecationPredicate = true;
> > + DeprecatedReason =
> > R->getValueAsString("ComplexDeprecationPredicate");
> > + } else if (RecordVal *Dep =
> > R->getValue("DeprecatedFeatureMask"))
> > {
> > + // Check if we have a Subtarget feature mask.
> > + HasComplexDeprecationPredicate = false;
> > + DeprecatedReason = Dep->getValue()->getAsString();
> > + } else {
> > + // This instruction isn't deprecated.
> > + HasComplexDeprecationPredicate = false;
> > + DeprecatedReason = "";
> > + }
> > }
> >
> > /// HasOneImplicitDefWithKnownVT - If the instruction has at least
> > one
> >
> > Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.h
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.h?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/utils/TableGen/CodeGenInstruction.h (original)
> > +++ llvm/trunk/utils/TableGen/CodeGenInstruction.h Thu Sep 12
> > 05:28:05 2013
> > @@ -248,6 +248,9 @@ namespace llvm {
> > bool isCodeGenOnly;
> > bool isPseudo;
> >
> > + std::string DeprecatedReason;
> > + bool HasComplexDeprecationPredicate;
> > +
> > /// Are there any undefined flags?
> > bool hasUndefFlags() const {
> > return mayLoad_Unset || mayStore_Unset ||
> > hasSideEffects_Unset;
> >
> > Modified: llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=190598&r1=190597&r2=190598&view=diff
> > ==============================================================================
> > --- llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp (original)
> > +++ llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Thu Sep 12
> > 05:28:05 2013
> > @@ -514,6 +514,19 @@ void InstrInfoEmitter::emitRecord(const
> > else
> > OS << "OperandInfo" << OpInfo.find(OperandInfo)->second;
> >
> > + CodeGenTarget &Target = CDP.getTargetInfo();
> > + if (Inst.HasComplexDeprecationPredicate)
> > + // Emit a function pointer to the complex predicate method.
> > + OS << ",0"
> > + << ",&get" << Inst.DeprecatedReason << "DeprecationInfo";
> > + else if (!Inst.DeprecatedReason.empty())
> > + // Emit the Subtarget feature.
> > + OS << "," << Target.getInstNamespace() << "::" <<
> > Inst.DeprecatedReason
> > + << ",0";
> > + else
> > + // Instruction isn't deprecated.
> > + OS << ",0,0";
> > +
> > OS << " }, // Inst #" << Num << " = " << Inst.TheDef->getName()
> > << "\n";
> > }
> >
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >
>
> --
> Hal Finkel
> Assistant Computational Scientist
> Leadership Computing Facility
> Argonne National Laboratory
>
>
>
>
>
--
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-commits
mailing list