[llvm-commits] [llvm] r170477 - in /llvm/trunk: include/llvm-c/Disassembler.h lib/MC/MCDisassembler/Disassembler.cpp lib/MC/MCDisassembler/Disassembler.h
Alex Rosenberg
alexr at leftfield.org
Tue Dec 18 17:46:48 PST 2012
Just to be pedantic: PPC and ARM both have legacy syntaxes.
Sent from my iPad
On Dec 18, 2012, at 3:47 PM, Kevin Enderby <enderby at apple.com> wrote:
> Author: enderby
> Date: Tue Dec 18 17:47:28 2012
> New Revision: 170477
>
> URL: http://llvm.org/viewvc/llvm-project?rev=170477&view=rev
> Log:
> Add to the disassembler C API an option to print the disassembled
> instructions in the assembly code variant if one exists.
>
> The intended use for this is so tools like lldb and darwin's otool(1)
> can be switched to print Intel-flavored disassembly.
>
> I discussed extensively this API with Jim Grosbach and we feel
> while it may not be fully general, in reality there is only one syntax
> for each assembly with the exception of X86 which has exactly
> two for historical reasons.
>
> rdar://10989182
>
> Modified:
> llvm/trunk/include/llvm-c/Disassembler.h
> llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp
> llvm/trunk/lib/MC/MCDisassembler/Disassembler.h
>
> Modified: llvm/trunk/include/llvm-c/Disassembler.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Disassembler.h?rev=170477&r1=170476&r2=170477&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm-c/Disassembler.h (original)
> +++ llvm/trunk/include/llvm-c/Disassembler.h Tue Dec 18 17:47:28 2012
> @@ -168,6 +168,8 @@
> #define LLVMDisassembler_Option_UseMarkup 1
> /* The option to print immediates as hex. */
> #define LLVMDisassembler_Option_PrintImmHex 2
> +/* The option use the other assembler printer variant */
> +#define LLVMDisassembler_Option_AsmPrinterVariant 4
>
> /**
> * Dispose of a disassembler context.
>
> Modified: llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp?rev=170477&r1=170476&r2=170477&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp (original)
> +++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp Tue Dec 18 17:47:28 2012
> @@ -195,5 +195,21 @@
> IP->setPrintImmHex(1);
> Options &= ~LLVMDisassembler_Option_PrintImmHex;
> }
> + if (Options & LLVMDisassembler_Option_AsmPrinterVariant){
> + LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR;
> + // Try to set up the new instruction printer.
> + const MCAsmInfo *MAI = DC->getAsmInfo();
> + const MCInstrInfo *MII = DC->getInstrInfo();
> + const MCRegisterInfo *MRI = DC->getRegisterInfo();
> + const MCSubtargetInfo *STI = DC->getSubtargetInfo();
> + int AsmPrinterVariant = MAI->getAssemblerDialect();
> + AsmPrinterVariant = AsmPrinterVariant == 0 ? 1 : 0;
> + MCInstPrinter *IP = DC->getTarget()->createMCInstPrinter(
> + AsmPrinterVariant, *MAI, *MII, *MRI, *STI);
> + if (IP) {
> + DC->setIP(IP);
> + Options &= ~LLVMDisassembler_Option_AsmPrinterVariant;
> + }
> + }
> return (Options == 0);
> }
>
> Modified: llvm/trunk/lib/MC/MCDisassembler/Disassembler.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.h?rev=170477&r1=170476&r2=170477&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCDisassembler/Disassembler.h (original)
> +++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.h Tue Dec 18 17:47:28 2012
> @@ -109,7 +109,11 @@
> const Target *getTarget() const { return TheTarget; }
> const MCDisassembler *getDisAsm() const { return DisAsm.get(); }
> const MCAsmInfo *getAsmInfo() const { return MAI.get(); }
> + const MCInstrInfo *getInstrInfo() const { return MII.get(); }
> + const MCRegisterInfo *getRegisterInfo() const { return MRI.get(); }
> + const MCSubtargetInfo *getSubtargetInfo() const { return MSI.get(); }
> MCInstPrinter *getIP() { return IP.get(); }
> + void setIP(MCInstPrinter *NewIP) { IP.reset(NewIP); }
> };
>
> } // namespace llvm
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list