1a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner//===-- llvm/CodeGen/AsmPrinter.h - AsmPrinter Framework --------*- C++ -*-===// 2ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman// 3a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner// The LLVM Compiler Infrastructure 4a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner// 57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source 67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details. 7ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman// 8a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner//===----------------------------------------------------------------------===// 9a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner// 10563321a2582851c653d0863e8e0bba3d483734f9Jim Laskey// This file contains a class to be used as the base class for target specific 11563321a2582851c653d0863e8e0bba3d483734f9Jim Laskey// asm writers. This class primarily handles common functionality used by 12563321a2582851c653d0863e8e0bba3d483734f9Jim Laskey// all asm writers. 13a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner// 14a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner//===----------------------------------------------------------------------===// 15a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner 16a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner#ifndef LLVM_CODEGEN_ASMPRINTER_H 17a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner#define LLVM_CODEGEN_ASMPRINTER_H 18a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner 19a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner#include "llvm/CodeGen/MachineFunctionPass.h" 200b8c9a80f20772c3793201ab5b251d3520b9cea3Chandler Carruth#include "llvm/IR/InlineAsm.h" 211f6efa3996dd1929fbc129203ce5009b620e6969Michael J. Spencer#include "llvm/Support/DataTypes.h" 2250bee42b54cd9aec5f49566307df2b0cf23afcf6Craig Topper#include "llvm/Support/ErrorHandling.h" 23a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner 24a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattnernamespace llvm { 258c2b52552c90f39e4b2fed43e309e599e742b6acDan Gohman class BlockAddress; 265eca075b74d62c621b160aa216b4cd50829a2cc7Gordon Henriksen class GCStrategy; 27a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner class Constant; 28c317a60c2714a5b90700a11ba646285cb754a5d3Gordon Henriksen class GCMetadataPrinter; 29fe37ab335be5632eab561d49984c95cb06b946d4David Greene class GlobalValue; 30ed13893ff729bc3b91697f6d80a3ba303782efccChris Lattner class GlobalVariable; 31fe37ab335be5632eab561d49984c95cb06b946d4David Greene class MachineBasicBlock; 32fe37ab335be5632eab561d49984c95cb06b946d4David Greene class MachineFunction; 33fe37ab335be5632eab561d49984c95cb06b946d4David Greene class MachineInstr; 3428ff35d030e2f49ff4e4b1544c015ebe011a530bDevang Patel class MachineLocation; 35b71d1b2fe2c0673005283b48be2f37c750ce367bDavid Greene class MachineLoopInfo; 36b71d1b2fe2c0673005283b48be2f37c750ce367bDavid Greene class MachineLoop; 37d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng class MachineConstantPoolValue; 38fe37ab335be5632eab561d49984c95cb06b946d4David Greene class MachineJumpTableInfo; 390de1fc4f416b3e94749ca84cdaede55b040a8b60Chris Lattner class MachineModuleInfo; 4002b86b93dc4616571fed3473c6da9421c10f2fccChris Lattner class MachineMove; 4149cd6649e1246c05896fadefe2fcbc4bc1f5d221Chris Lattner class MCAsmInfo; 422b2954f00ba02ca1a902f47080cd9f06aebc0378Chris Lattner class MCContext; 43a87dea4f8c546ca748f1777a8d1cabcc06515d91Chris Lattner class MCSection; 442b2954f00ba02ca1a902f47080cd9f06aebc0378Chris Lattner class MCStreamer; 457cb384dcca3f1ccfc993182ee4b972f7fffc8ffaChris Lattner class MCSymbol; 46a38941d458273946594d3592ed5debdc9730db08Chris Lattner class MDNode; 4749cd6649e1246c05896fadefe2fcbc4bc1f5d221Chris Lattner class DwarfDebug; 4849cd6649e1246c05896fadefe2fcbc4bc1f5d221Chris Lattner class DwarfException; 49563321a2582851c653d0863e8e0bba3d483734f9Jim Laskey class Mangler; 50f0144127b98425d214e59e4a1a4b342b78e3642bChris Lattner class TargetLoweringObjectFile; 513574eca1b02600bac4e625297f4ecf745f4c4f32Micah Villmow class DataLayout; 5211112e0d7b1fb2741ed65a5085037918d1425916Dan Gohman class TargetMachine; 53a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner 54563321a2582851c653d0863e8e0bba3d483734f9Jim Laskey /// AsmPrinter - This class is intended to be used as a driving class for all 55563321a2582851c653d0863e8e0bba3d483734f9Jim Laskey /// asm writers. 56a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner class AsmPrinter : public MachineFunctionPass { 573f53c8398d81065736a784469c9dd5afff85673fChris Lattner public: 58a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner /// Target machine description. 59a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner /// 60a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner TargetMachine &TM; 61dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 62563321a2582851c653d0863e8e0bba3d483734f9Jim Laskey /// Target Asm Printer information. 63563321a2582851c653d0863e8e0bba3d483734f9Jim Laskey /// 6433adcfb4d217f5f23d9bde8ba02b8e48f9605fc5Chris Lattner const MCAsmInfo *MAI; 65a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner 662b2954f00ba02ca1a902f47080cd9f06aebc0378Chris Lattner /// OutContext - This is the context for the output file that we are 672b2954f00ba02ca1a902f47080cd9f06aebc0378Chris Lattner /// streaming. This owns all of the global MC-related objects for the 682b2954f00ba02ca1a902f47080cd9f06aebc0378Chris Lattner /// generated translation unit. 692b2954f00ba02ca1a902f47080cd9f06aebc0378Chris Lattner MCContext &OutContext; 70dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 712b2954f00ba02ca1a902f47080cd9f06aebc0378Chris Lattner /// OutStreamer - This is the MCStreamer object for the file we are 722b2954f00ba02ca1a902f47080cd9f06aebc0378Chris Lattner /// generating. This contains the transient state for the current 732b2954f00ba02ca1a902f47080cd9f06aebc0378Chris Lattner /// translation unit that we are generating (such as the current section 742b2954f00ba02ca1a902f47080cd9f06aebc0378Chris Lattner /// etc). 752b2954f00ba02ca1a902f47080cd9f06aebc0378Chris Lattner MCStreamer &OutStreamer; 76dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 7757f0db833dc30404f1f5d28b23df326e520698ecBill Wendling /// The current machine function. 7857f0db833dc30404f1f5d28b23df326e520698ecBill Wendling const MachineFunction *MF; 7957f0db833dc30404f1f5d28b23df326e520698ecBill Wendling 80300a4c5640fb1c717ba0d7108d15aec1bd7eb396Chris Lattner /// MMI - This is a pointer to the current MachineModuleInfo. 81300a4c5640fb1c717ba0d7108d15aec1bd7eb396Chris Lattner MachineModuleInfo *MMI; 82300a4c5640fb1c717ba0d7108d15aec1bd7eb396Chris Lattner 83a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner /// Name-mangler for global names. 84a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner /// 85a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner Mangler *Mang; 86a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner 87412c3a5bc9e70fe8579551216786e70d323a3dd5Chris Lattner /// The symbol for the current function. This is recalculated at the 88a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner /// beginning of each call to runOnMachineFunction(). 89a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner /// 905957c84e09b177aecf8b430c33fd75a36575fb57Chris Lattner MCSymbol *CurrentFnSym; 91dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 92d55a2664f9493a4c3be242a75d339fac0ebe2e21Hal Finkel /// The symbol used to represent the start of the current function for the 93d55a2664f9493a4c3be242a75d339fac0ebe2e21Hal Finkel /// purpose of calculating its size (e.g. using the .size directive). By 94d55a2664f9493a4c3be242a75d339fac0ebe2e21Hal Finkel /// default, this is equal to CurrentFnSym. 95d55a2664f9493a4c3be242a75d339fac0ebe2e21Hal Finkel MCSymbol *CurrentFnSymForSize; 96d55a2664f9493a4c3be242a75d339fac0ebe2e21Hal Finkel 97e00b59f954c7e27d9d34abf90bfac969fb12f19aChris Lattner private: 98e00b59f954c7e27d9d34abf90bfac969fb12f19aChris Lattner // GCMetadataPrinters - The garbage collection metadata printer table. 99e00b59f954c7e27d9d34abf90bfac969fb12f19aChris Lattner void *GCMetadataPrinters; // Really a DenseMap. 100dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 1013f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// VerboseAsm - Emit comments in assembly output if this is true. 1023f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// 1033f53c8398d81065736a784469c9dd5afff85673fChris Lattner bool VerboseAsm; 1043f53c8398d81065736a784469c9dd5afff85673fChris Lattner static char ID; 105dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 1063f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// If VerboseAsm is set, a pointer to the loop info for this 1073f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// function. 1083f53c8398d81065736a784469c9dd5afff85673fChris Lattner MachineLoopInfo *LI; 10949cd6649e1246c05896fadefe2fcbc4bc1f5d221Chris Lattner 11049cd6649e1246c05896fadefe2fcbc4bc1f5d221Chris Lattner /// DD - If the target supports dwarf debug info, this pointer is non-null. 11149cd6649e1246c05896fadefe2fcbc4bc1f5d221Chris Lattner DwarfDebug *DD; 112dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 11349cd6649e1246c05896fadefe2fcbc4bc1f5d221Chris Lattner /// DE - If the target supports dwarf exception info, this pointer is 11449cd6649e1246c05896fadefe2fcbc4bc1f5d221Chris Lattner /// non-null. 11549cd6649e1246c05896fadefe2fcbc4bc1f5d221Chris Lattner DwarfException *DE; 116dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 117b2efb853f00d45b1c8d57f92acd0028fbdeffda6Jim Laskey protected: 118b23569aff0a6d2b231cb93cc4acd0ac060ba560fChris Lattner explicit AsmPrinter(TargetMachine &TM, MCStreamer &Streamer); 119dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 120a7cea6f599418a579ab5ce66413fba7efa8bf581Jim Laskey public: 121c317a60c2714a5b90700a11ba646285cb754a5d3Gordon Henriksen virtual ~AsmPrinter(); 12242bf74be1402df7409efbea089310d4c276fde37Evan Cheng 12342bf74be1402df7409efbea089310d4c276fde37Evan Cheng /// isVerbose - Return true if assembly output should contain comments. 12442bf74be1402df7409efbea089310d4c276fde37Evan Cheng /// 12542bf74be1402df7409efbea089310d4c276fde37Evan Cheng bool isVerbose() const { return VerboseAsm; } 12642bf74be1402df7409efbea089310d4c276fde37Evan Cheng 1273fb2b1ede30193b59a651328a946174196b20610Jim Grosbach /// getFunctionNumber - Return a unique ID for the current function. 1283fb2b1ede30193b59a651328a946174196b20610Jim Grosbach /// 129b84822fb7b64977c16e97b870891da1d6c9736feChris Lattner unsigned getFunctionNumber() const; 130dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 131d38fee8ddc6597555904b82b6471a446cc5fe183Chris Lattner /// getObjFileLowering - Return information about object file lowering. 1320d805c33d134d88169e3dc4a3272cff9a5713ce7Dan Gohman const TargetLoweringObjectFile &getObjFileLowering() const; 133d38fee8ddc6597555904b82b6471a446cc5fe183Chris Lattner 1343574eca1b02600bac4e625297f4ecf745f4c4f32Micah Villmow /// getDataLayout - Return information about data layout. 1353574eca1b02600bac4e625297f4ecf745f4c4f32Micah Villmow const DataLayout &getDataLayout() const; 136d38fee8ddc6597555904b82b6471a446cc5fe183Chris Lattner 137d38fee8ddc6597555904b82b6471a446cc5fe183Chris Lattner /// getCurrentSection() - Return the current section we are emitting to. 138d38fee8ddc6597555904b82b6471a446cc5fe183Chris Lattner const MCSection *getCurrentSection() const; 139dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 140dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 1413f53c8398d81065736a784469c9dd5afff85673fChris Lattner //===------------------------------------------------------------------===// 1423f53c8398d81065736a784469c9dd5afff85673fChris Lattner // MachineFunctionPass Implementation. 1433f53c8398d81065736a784469c9dd5afff85673fChris Lattner //===------------------------------------------------------------------===// 144dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 145ce2247755e56f99a2377b64a1a9d393726582b85Gordon Henriksen /// getAnalysisUsage - Record analysis usage. 146dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov /// 147ce2247755e56f99a2377b64a1a9d393726582b85Gordon Henriksen void getAnalysisUsage(AnalysisUsage &AU) const; 148dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 149a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner /// doInitialization - Set up the AsmPrinter when we are working on a new 150a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner /// module. If your pass overrides this, it must make sure to explicitly 151a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner /// call this implementation. 152a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner bool doInitialization(Module &M); 153a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner 154a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner /// doFinalization - Shut down the asmprinter. If you override this in your 155a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner /// pass, you must make sure to call it explicitly. 156a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner bool doFinalization(Module &M); 157dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 158d49fe1b6bc4615684c2ec71140a21e9c4cd69ce3Chris Lattner /// runOnMachineFunction - Emit the specified function out to the 159d49fe1b6bc4615684c2ec71140a21e9c4cd69ce3Chris Lattner /// OutStreamer. 160d49fe1b6bc4615684c2ec71140a21e9c4cd69ce3Chris Lattner virtual bool runOnMachineFunction(MachineFunction &MF) { 161d49fe1b6bc4615684c2ec71140a21e9c4cd69ce3Chris Lattner SetupMachineFunction(MF); 162d49fe1b6bc4615684c2ec71140a21e9c4cd69ce3Chris Lattner EmitFunctionHeader(); 163d49fe1b6bc4615684c2ec71140a21e9c4cd69ce3Chris Lattner EmitFunctionBody(); 164d49fe1b6bc4615684c2ec71140a21e9c4cd69ce3Chris Lattner return false; 165dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov } 166dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 1673f53c8398d81065736a784469c9dd5afff85673fChris Lattner //===------------------------------------------------------------------===// 1683f53c8398d81065736a784469c9dd5afff85673fChris Lattner // Coarse grained IR lowering routines. 1693f53c8398d81065736a784469c9dd5afff85673fChris Lattner //===------------------------------------------------------------------===// 170dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 1716fe3acce749ee2b3714009064626f6c53b06dfb4Chris Lattner /// SetupMachineFunction - This should be called when a new MachineFunction 172a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner /// is being processed from runOnMachineFunction. 1736fe3acce749ee2b3714009064626f6c53b06dfb4Chris Lattner void SetupMachineFunction(MachineFunction &MF); 174dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 175b11caedd6f36afc6518cf0ea9bbff6500fd77334Chris Lattner /// EmitFunctionHeader - This method emits the header for the current 176b11caedd6f36afc6518cf0ea9bbff6500fd77334Chris Lattner /// function. 177b11caedd6f36afc6518cf0ea9bbff6500fd77334Chris Lattner void EmitFunctionHeader(); 178dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 17914c38ec2afeaf25c53a50c2c65116aca8c889401Chris Lattner /// EmitFunctionBody - This method emits the body and trailer for a 18014c38ec2afeaf25c53a50c2c65116aca8c889401Chris Lattner /// function. 18114c38ec2afeaf25c53a50c2c65116aca8c889401Chris Lattner void EmitFunctionBody(); 182b11caedd6f36afc6518cf0ea9bbff6500fd77334Chris Lattner 183f0adba9a7ec8a3031876575a6ffb7db5f1b6f855Rafael Espindola void emitPrologLabel(const MachineInstr &MI); 184f0adba9a7ec8a3031876575a6ffb7db5f1b6f855Rafael Espindola 185e29887b4ee42ae78790a8c1886a7babee9ef18e5Rafael Espindola enum CFIMoveType { 186e29887b4ee42ae78790a8c1886a7babee9ef18e5Rafael Espindola CFI_M_None, 187e29887b4ee42ae78790a8c1886a7babee9ef18e5Rafael Espindola CFI_M_EH, 188e29887b4ee42ae78790a8c1886a7babee9ef18e5Rafael Espindola CFI_M_Debug 189e29887b4ee42ae78790a8c1886a7babee9ef18e5Rafael Espindola }; 190e29887b4ee42ae78790a8c1886a7babee9ef18e5Rafael Espindola CFIMoveType needsCFIMoves(); 191a432997745f668e85e45826106430f69238b1d1eRafael Espindola 192f46337004ab08076774932785679460ec3d3bb9aCharles Davis bool needsSEHMoves(); 193f46337004ab08076774932785679460ec3d3bb9aCharles Davis 194390c40d96adb2eb4a778a0890c6c8743057e289eNick Lewycky /// needsRelocationsForDwarfStringPool - Specifies whether the object format 195390c40d96adb2eb4a778a0890c6c8743057e289eNick Lewycky /// expects to use relocations to refer to debug entries. Alternatively we 196390c40d96adb2eb4a778a0890c6c8743057e289eNick Lewycky /// emit section offsets in bytes from the start of the string pool. 197390c40d96adb2eb4a778a0890c6c8743057e289eNick Lewycky bool needsRelocationsForDwarfStringPool() const; 198390c40d96adb2eb4a778a0890c6c8743057e289eNick Lewycky 199ed13893ff729bc3b91697f6d80a3ba303782efccChris Lattner /// EmitConstantPool - Print to the current output stream assembly 200ed13893ff729bc3b91697f6d80a3ba303782efccChris Lattner /// representations of the constants in the constant pool MCP. This is 201ed13893ff729bc3b91697f6d80a3ba303782efccChris Lattner /// used to print out constants which have been "spilled to memory" by 202ed13893ff729bc3b91697f6d80a3ba303782efccChris Lattner /// the code generator. 203ed13893ff729bc3b91697f6d80a3ba303782efccChris Lattner /// 204a2406190ca28dc5901dfe747849c8eda9c29d7eeChris Lattner virtual void EmitConstantPool(); 205dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 206dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov /// EmitJumpTableInfo - Print assembly representations of the jump tables 207dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov /// used by the current function to the current output stream. 20837efe6764568a3829fee26aba532283131d1a104Nate Begeman /// 20914c38ec2afeaf25c53a50c2c65116aca8c889401Chris Lattner void EmitJumpTableInfo(); 210dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 21148d64ba9d846229339b2431b298620cb8a01ffc5Chris Lattner /// EmitGlobalVariable - Emit the specified global variable to the .s file. 21274bfe21b50c14c15f55ce3bd5857d65b588fae3cChris Lattner virtual void EmitGlobalVariable(const GlobalVariable *GV); 213dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 214ed13893ff729bc3b91697f6d80a3ba303782efccChris Lattner /// EmitSpecialLLVMGlobal - Check to see if the specified global is a 215ed13893ff729bc3b91697f6d80a3ba303782efccChris Lattner /// special global used by LLVM. If so, emit it and return true, otherwise 216ed13893ff729bc3b91697f6d80a3ba303782efccChris Lattner /// do nothing and return false. 217ed13893ff729bc3b91697f6d80a3ba303782efccChris Lattner bool EmitSpecialLLVMGlobal(const GlobalVariable *GV); 21887370b8301fa39ee54bdcaae0618fd565e808466Devang Patel 219c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner /// EmitAlignment - Emit an alignment directive to the specified power of 220c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner /// two boundary. For example, if you pass in 3 here, you will get an 8 221c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner /// byte alignment. If a global value is specified, and if that global has 222e87f7bb50e1d08a09e29252806f6502dcff0539dChris Lattner /// an explicit alignment requested, it will override the alignment request 223e87f7bb50e1d08a09e29252806f6502dcff0539dChris Lattner /// if required for correctness. 224c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner /// 225a7b611c10d0e5fef5870d854518e639ce3d3c6beChris Lattner void EmitAlignment(unsigned NumBits, const GlobalValue *GV = 0) const; 226dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 227c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner /// EmitBasicBlockStart - This method prints the label for the specified 228c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner /// MachineBasicBlock, an alignment (if present) and a comment describing 229c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner /// it if appropriate. 230c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner void EmitBasicBlockStart(const MachineBasicBlock *MBB) const; 231dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 232c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner /// EmitGlobalConstant - Print a general LLVM constant to the .s file. 233c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner void EmitGlobalConstant(const Constant *CV, unsigned AddrSpace = 0); 234dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 235dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 236f1cdea1d021068f5c9e118d68321ce28fcea63faJim Laskey //===------------------------------------------------------------------===// 2373f53c8398d81065736a784469c9dd5afff85673fChris Lattner // Overridable Hooks 2383f53c8398d81065736a784469c9dd5afff85673fChris Lattner //===------------------------------------------------------------------===// 239dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 2403f53c8398d81065736a784469c9dd5afff85673fChris Lattner // Targets can, or in the case of EmitInstruction, must implement these to 2413f53c8398d81065736a784469c9dd5afff85673fChris Lattner // customize output. 242dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 2433f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// EmitStartOfAsmFile - This virtual method can be overridden by targets 2443f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// that want to emit something at the start of their file. 2453f53c8398d81065736a784469c9dd5afff85673fChris Lattner virtual void EmitStartOfAsmFile(Module &) {} 246dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 2473f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// EmitEndOfAsmFile - This virtual method can be overridden by targets that 2483f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// want to emit something at the end of their file. 2493f53c8398d81065736a784469c9dd5afff85673fChris Lattner virtual void EmitEndOfAsmFile(Module &) {} 250dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 2513f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// EmitFunctionBodyStart - Targets can override this to emit stuff before 2523f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// the first basic block in the function. 2533f53c8398d81065736a784469c9dd5afff85673fChris Lattner virtual void EmitFunctionBodyStart() {} 254dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 2553f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// EmitFunctionBodyEnd - Targets can override this to emit stuff after 2563f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// the last basic block in the function. 2573f53c8398d81065736a784469c9dd5afff85673fChris Lattner virtual void EmitFunctionBodyEnd() {} 258dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 2593f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// EmitInstruction - Targets should implement this to emit instructions. 2603f53c8398d81065736a784469c9dd5afff85673fChris Lattner virtual void EmitInstruction(const MachineInstr *) { 26150bee42b54cd9aec5f49566307df2b0cf23afcf6Craig Topper llvm_unreachable("EmitInstruction not implemented"); 2623f53c8398d81065736a784469c9dd5afff85673fChris Lattner } 263dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 26417fedf216bc10c66e02694854f522cb602097005Chris Lattner virtual void EmitFunctionEntryLabel(); 265dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 26617fedf216bc10c66e02694854f522cb602097005Chris Lattner virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV); 267dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 2685b676ce7932cf60d4fd6d101323d8d54b8395804Chris Lattner /// EmitXXStructor - Targets can override this to change how global 2695b676ce7932cf60d4fd6d101323d8d54b8395804Chris Lattner /// constants that are part of a C++ static/global constructor list are 2705b676ce7932cf60d4fd6d101323d8d54b8395804Chris Lattner /// emitted. 27134982576a43887e7f062ed0a3571af2cbab003f3James Molloy virtual void EmitXXStructor(const Constant *CV) { 27234982576a43887e7f062ed0a3571af2cbab003f3James Molloy EmitGlobalConstant(CV); 27334982576a43887e7f062ed0a3571af2cbab003f3James Molloy } 27434982576a43887e7f062ed0a3571af2cbab003f3James Molloy 27517fedf216bc10c66e02694854f522cb602097005Chris Lattner /// isBlockOnlyReachableByFallthough - Return true if the basic block has 27617fedf216bc10c66e02694854f522cb602097005Chris Lattner /// exactly one predecessor and the control transfer mechanism between 27717fedf216bc10c66e02694854f522cb602097005Chris Lattner /// the predecessor and this block is a fall-through. 27817fedf216bc10c66e02694854f522cb602097005Chris Lattner virtual bool 27917fedf216bc10c66e02694854f522cb602097005Chris Lattner isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const; 280dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 281f1cdea1d021068f5c9e118d68321ce28fcea63faJim Laskey //===------------------------------------------------------------------===// 282c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner // Symbol Lowering Routines. 2833f53c8398d81065736a784469c9dd5afff85673fChris Lattner //===------------------------------------------------------------------===// 2843f53c8398d81065736a784469c9dd5afff85673fChris Lattner public: 285f1cdea1d021068f5c9e118d68321ce28fcea63faJim Laskey 286c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner /// GetTempSymbol - Return the MCSymbol corresponding to the assembler 287c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner /// temporary label with the specified stem and unique ID. 288c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner MCSymbol *GetTempSymbol(StringRef Name, unsigned ID) const; 289dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 290c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner /// GetTempSymbol - Return an assembler temporary label with the specified 291c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner /// stem. 292c021572511f08372ae52fe8e31d3c307cab448fdChris Lattner MCSymbol *GetTempSymbol(StringRef Name) const; 293dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 294dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 2957a2ba94d03b43f41b54872dacd7b2250dde4c7bdChris Lattner /// GetSymbolWithGlobalValueBase - Return the MCSymbol for a symbol with 296d588b97cc9acf778282ab10efa4f298cead1215aChris Lattner /// global value name as its base, with the specified suffix, and where the 2977a2ba94d03b43f41b54872dacd7b2250dde4c7bdChris Lattner /// symbol is forced to have private linkage if ForcePrivate is true. 2987a2ba94d03b43f41b54872dacd7b2250dde4c7bdChris Lattner MCSymbol *GetSymbolWithGlobalValueBase(const GlobalValue *GV, 2997a2ba94d03b43f41b54872dacd7b2250dde4c7bdChris Lattner StringRef Suffix, 3007a2ba94d03b43f41b54872dacd7b2250dde4c7bdChris Lattner bool ForcePrivate = true) const; 301dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 3026b04edee11c2bb35a48b1c42f867b4ba8cdfff97Chris Lattner /// GetExternalSymbolSymbol - Return the MCSymbol for the specified 3036b04edee11c2bb35a48b1c42f867b4ba8cdfff97Chris Lattner /// ExternalSymbol. 3046b04edee11c2bb35a48b1c42f867b4ba8cdfff97Chris Lattner MCSymbol *GetExternalSymbolSymbol(StringRef Sym) const; 305dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 3063924868a957d5a6d468b61741cbb7db77324d1f6Chris Lattner /// GetCPISymbol - Return the symbol for the specified constant pool entry. 3073924868a957d5a6d468b61741cbb7db77324d1f6Chris Lattner MCSymbol *GetCPISymbol(unsigned CPID) const; 3083924868a957d5a6d468b61741cbb7db77324d1f6Chris Lattner 3093924868a957d5a6d468b61741cbb7db77324d1f6Chris Lattner /// GetJTISymbol - Return the symbol for the specified jump table entry. 31007d317711781d8c9268f7d6afcf1ba7eadf1d127Bill Wendling MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const; 3113924868a957d5a6d468b61741cbb7db77324d1f6Chris Lattner 312798d1256595dcc0f5d4423572f856d239f7de0e6Chris Lattner /// GetJTSetSymbol - Return the symbol for the specified jump table .set 313798d1256595dcc0f5d4423572f856d239f7de0e6Chris Lattner /// FIXME: privatize to AsmPrinter. 314798d1256595dcc0f5d4423572f856d239f7de0e6Chris Lattner MCSymbol *GetJTSetSymbol(unsigned UID, unsigned MBBID) const; 315798d1256595dcc0f5d4423572f856d239f7de0e6Chris Lattner 3168c2b52552c90f39e4b2fed43e309e599e742b6acDan Gohman /// GetBlockAddressSymbol - Return the MCSymbol used to satisfy BlockAddress 3178c2b52552c90f39e4b2fed43e309e599e742b6acDan Gohman /// uses of the specified basic block. 318951755445821b92c3dc38f32b5c36e9875fa4318Chris Lattner MCSymbol *GetBlockAddressSymbol(const BlockAddress *BA) const; 3193b9d6216a41cfd43759e787db26d797e1f0ba0a8Chris Lattner MCSymbol *GetBlockAddressSymbol(const BasicBlock *BB) const; 3208c2b52552c90f39e4b2fed43e309e599e742b6acDan Gohman 3216215109cd967190a3d005d1e2e284cd51e45eadcJim Grosbach //===------------------------------------------------------------------===// 3223f53c8398d81065736a784469c9dd5afff85673fChris Lattner // Emission Helper Routines. 3233f53c8398d81065736a784469c9dd5afff85673fChris Lattner //===------------------------------------------------------------------===// 3243f53c8398d81065736a784469c9dd5afff85673fChris Lattner public: 32517fedf216bc10c66e02694854f522cb602097005Chris Lattner /// printOffset - This is just convenient handler for printing offsets. 32617fedf216bc10c66e02694854f522cb602097005Chris Lattner void printOffset(int64_t Offset, raw_ostream &OS) const; 327dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 3283f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// EmitInt8 - Emit a byte directive and value. 3293f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// 3303f53c8398d81065736a784469c9dd5afff85673fChris Lattner void EmitInt8(int Value) const; 331dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 3323f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// EmitInt16 - Emit a short directive and value. 3333f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// 3343f53c8398d81065736a784469c9dd5afff85673fChris Lattner void EmitInt16(int Value) const; 335dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 3363f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// EmitInt32 - Emit a long directive and value. 3373f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// 3383f53c8398d81065736a784469c9dd5afff85673fChris Lattner void EmitInt32(int Value) const; 339dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 3403f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// EmitLabelDifference - Emit something like ".long Hi-Lo" where the size 3413f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// in bytes of the directive is specified by Size and Hi/Lo specify the 3423f53c8398d81065736a784469c9dd5afff85673fChris Lattner /// labels. This implicitly uses .set if it is available. 3433f53c8398d81065736a784469c9dd5afff85673fChris Lattner void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, 3443f53c8398d81065736a784469c9dd5afff85673fChris Lattner unsigned Size) const; 345dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 346dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov /// EmitLabelOffsetDifference - Emit something like ".long Hi+Offset-Lo" 347f2548caaa8b290aa598bf49c27dff72f7751ba5cDevang Patel /// where the size in bytes of the directive is specified by Size and Hi/Lo 348f2548caaa8b290aa598bf49c27dff72f7751ba5cDevang Patel /// specify the labels. This implicitly uses .set if it is available. 349f2548caaa8b290aa598bf49c27dff72f7751ba5cDevang Patel void EmitLabelOffsetDifference(const MCSymbol *Hi, uint64_t Offset, 350f2548caaa8b290aa598bf49c27dff72f7751ba5cDevang Patel const MCSymbol *Lo, unsigned Size) const; 351dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 352b1fcfbe89bd155fb88485b2a3a995adba3994003Devang Patel /// EmitLabelPlusOffset - Emit something like ".long Label+Offset" 353b1fcfbe89bd155fb88485b2a3a995adba3994003Devang Patel /// where the size in bytes of the directive is specified by Size and Label 354b1fcfbe89bd155fb88485b2a3a995adba3994003Devang Patel /// specifies the label. This implicitly uses .set if it is available. 355b1fcfbe89bd155fb88485b2a3a995adba3994003Devang Patel void EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, 356b1fcfbe89bd155fb88485b2a3a995adba3994003Devang Patel unsigned Size) const; 357b1fcfbe89bd155fb88485b2a3a995adba3994003Devang Patel 358ffccd923101ae177c1a2c407618d8f03a312d69bNick Lewycky /// EmitLabelReference - Emit something like ".long Label" 359ffccd923101ae177c1a2c407618d8f03a312d69bNick Lewycky /// where the size in bytes of the directive is specified by Size and Label 360ffccd923101ae177c1a2c407618d8f03a312d69bNick Lewycky /// specifies the label. 361ffccd923101ae177c1a2c407618d8f03a312d69bNick Lewycky void EmitLabelReference(const MCSymbol *Label, unsigned Size) const { 362ffccd923101ae177c1a2c407618d8f03a312d69bNick Lewycky EmitLabelPlusOffset(Label, 0, Size); 363ffccd923101ae177c1a2c407618d8f03a312d69bNick Lewycky } 364ffccd923101ae177c1a2c407618d8f03a312d69bNick Lewycky 3657e1a8f882f1baa1c0d5204373d6eb4cb7fc9f3eaChris Lattner //===------------------------------------------------------------------===// 3667e1a8f882f1baa1c0d5204373d6eb4cb7fc9f3eaChris Lattner // Dwarf Emission Helper Routines 3677e1a8f882f1baa1c0d5204373d6eb4cb7fc9f3eaChris Lattner //===------------------------------------------------------------------===// 368dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 3697e1a8f882f1baa1c0d5204373d6eb4cb7fc9f3eaChris Lattner /// EmitSLEB128 - emit the specified signed leb128 value. 3707e1a8f882f1baa1c0d5204373d6eb4cb7fc9f3eaChris Lattner void EmitSLEB128(int Value, const char *Desc = 0) const; 371dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 3727e1a8f882f1baa1c0d5204373d6eb4cb7fc9f3eaChris Lattner /// EmitULEB128 - emit the specified unsigned leb128 value. 3737e1a8f882f1baa1c0d5204373d6eb4cb7fc9f3eaChris Lattner void EmitULEB128(unsigned Value, const char *Desc = 0, 3747e1a8f882f1baa1c0d5204373d6eb4cb7fc9f3eaChris Lattner unsigned PadTo = 0) const; 375dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 3769be49131363f79ad58a5deb4daf175a7b1c0ec66Chris Lattner /// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value. 3779be49131363f79ad58a5deb4daf175a7b1c0ec66Chris Lattner void EmitCFAByte(unsigned Val) const; 3789be49131363f79ad58a5deb4daf175a7b1c0ec66Chris Lattner 3799be49131363f79ad58a5deb4daf175a7b1c0ec66Chris Lattner /// EmitEncodingByte - Emit a .byte 42 directive that corresponds to an 3809be49131363f79ad58a5deb4daf175a7b1c0ec66Chris Lattner /// encoding. If verbose assembly output is enabled, we output comments 3819be49131363f79ad58a5deb4daf175a7b1c0ec66Chris Lattner /// describing the encoding. Desc is a string saying what the encoding is 3829be49131363f79ad58a5deb4daf175a7b1c0ec66Chris Lattner /// specifying (e.g. "LSDA"). 38302b86b93dc4616571fed3473c6da9421c10f2fccChris Lattner void EmitEncodingByte(unsigned Val, const char *Desc = 0) const; 384dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 385d2af7853e377bce40cbf3e0632a4608484b6aba4Chris Lattner /// GetSizeOfEncodedValue - Return the size of the encoding in bytes. 386d2af7853e377bce40cbf3e0632a4608484b6aba4Chris Lattner unsigned GetSizeOfEncodedValue(unsigned Encoding) const; 387dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 38825efd6d556718295a63d37f5294985746af354f6Anton Korobeynikov /// EmitReference - Emit reference to a ttype global with a specified encoding. 38925efd6d556718295a63d37f5294985746af354f6Anton Korobeynikov void EmitTTypeReference(const GlobalValue *GV, unsigned Encoding) const; 390dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 3913c754aa81564727805be94089694abeb8fe65160Chris Lattner /// EmitSectionOffset - Emit the 4-byte offset of Label from the start of 3923c754aa81564727805be94089694abeb8fe65160Chris Lattner /// its section. This can be done with a special directive if the target 3933c754aa81564727805be94089694abeb8fe65160Chris Lattner /// supports it (e.g. cygwin) or by emitting it as an offset from a label at 3943c754aa81564727805be94089694abeb8fe65160Chris Lattner /// the start of the section. 3953c754aa81564727805be94089694abeb8fe65160Chris Lattner /// 3963c754aa81564727805be94089694abeb8fe65160Chris Lattner /// SectionLabel is a temporary label emitted at the start of the section 3973c754aa81564727805be94089694abeb8fe65160Chris Lattner /// that Label lives in. 3983c754aa81564727805be94089694abeb8fe65160Chris Lattner void EmitSectionOffset(const MCSymbol *Label, 3993c754aa81564727805be94089694abeb8fe65160Chris Lattner const MCSymbol *SectionLabel) const; 40028ff35d030e2f49ff4e4b1544c015ebe011a530bDevang Patel 40128ff35d030e2f49ff4e4b1544c015ebe011a530bDevang Patel /// getDebugValueLocation - Get location information encoded by DBG_VALUE 40228ff35d030e2f49ff4e4b1544c015ebe011a530bDevang Patel /// operands. 40328ff35d030e2f49ff4e4b1544c015ebe011a530bDevang Patel virtual MachineLocation getDebugValueLocation(const MachineInstr *MI) const; 40428ff35d030e2f49ff4e4b1544c015ebe011a530bDevang Patel 405917290043f87b8efa6ba540bec5963013c517912Jim Grosbach /// getISAEncoding - Get the value for DW_AT_APPLE_isa. Zero if no isa 406917290043f87b8efa6ba540bec5963013c517912Jim Grosbach /// encoding specified. 407917290043f87b8efa6ba540bec5963013c517912Jim Grosbach virtual unsigned getISAEncoding() { return 0; } 408917290043f87b8efa6ba540bec5963013c517912Jim Grosbach 409acc381bee95b5eafcdf3eaa85a66e83a5773aacbDevang Patel /// EmitDwarfRegOp - Emit dwarf register operation. 4100be77dff1147488814b8eea6ec8619f56e3d9f5eDevang Patel virtual void EmitDwarfRegOp(const MachineLocation &MLoc) const; 411acc381bee95b5eafcdf3eaa85a66e83a5773aacbDevang Patel 41202b86b93dc4616571fed3473c6da9421c10f2fccChris Lattner //===------------------------------------------------------------------===// 41302b86b93dc4616571fed3473c6da9421c10f2fccChris Lattner // Dwarf Lowering Routines 41402b86b93dc4616571fed3473c6da9421c10f2fccChris Lattner //===------------------------------------------------------------------===// 415dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 416ffa6408f9cb30cd639eb8eb71ee4aa6f48d0c7a7Rafael Espindola /// EmitCFIFrameMove - Emit frame instruction to describe the layout of the 41702b86b93dc4616571fed3473c6da9421c10f2fccChris Lattner /// frame. 418126ae6815263aeffe4fbaa6dff1e4428aa8f0a91Rafael Espindola void EmitCFIFrameMove(const MachineMove &Move) const; 419ffa6408f9cb30cd639eb8eb71ee4aa6f48d0c7a7Rafael Espindola 420736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner //===------------------------------------------------------------------===// 421736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner // Inline Asm Support 422736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner //===------------------------------------------------------------------===// 423736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner public: 424736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner // These are hooks that targets can override to implement inline asm 425736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner // support. These should probably be moved out of AsmPrinter someday. 426dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 427736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// PrintSpecial - Print information related to the specified machine instr 428736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// that is independent of the operand, and may be independent of the instr 429736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// itself. This can be useful for portably encoding the comment character 430736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// or other bits of target-specific knowledge into the asmstrings. The 431736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// syntax used is ${:comment}. Targets can override this to add support 432736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// for their own strange codes. 433736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner virtual void PrintSpecial(const MachineInstr *MI, raw_ostream &OS, 434736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner const char *Code) const; 435dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 436736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM 437736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// instruction, using the specified assembler variant. Targets should 438736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// override this to format as appropriate. This method can return true if 439736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// the operand is erroneous. 440736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, 441736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner unsigned AsmVariant, const char *ExtraCode, 442736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner raw_ostream &OS); 443dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 444736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// PrintAsmMemoryOperand - Print the specified operand of MI, an INLINEASM 445736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// instruction, using the specified assembler variant as an address. 446736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// Targets should override this to format as appropriate. This method can 447736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// return true if the operand is erroneous. 448736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, 449dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov unsigned AsmVariant, 450736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner const char *ExtraCode, 451736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner raw_ostream &OS); 452dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 453736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner private: 454736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// Private state for PrintSpecial() 455736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner // Assign a unique ID to this machine instruction. 456736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner mutable const MachineInstr *LastMI; 457736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner mutable unsigned LastFn; 458736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner mutable unsigned Counter; 459736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner mutable unsigned SetCounter; 460736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner 461736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// EmitInlineAsm - Emit a blob of inline asm to the output streamer. 462366df7945f0e65052d2e1df701ae1fd16b943642Chad Rosier void EmitInlineAsm(StringRef Str, const MDNode *LocMDNode = 0, 463366df7945f0e65052d2e1df701ae1fd16b943642Chad Rosier InlineAsm::AsmDialect AsmDialect = InlineAsm::AD_ATT) const; 464dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 465736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// EmitInlineAsm - This method formats and emits the specified machine 466736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner /// instruction that is an inline asm. 467736e31d0cfd8a28c31741f39be606a11e7fc0036Chris Lattner void EmitInlineAsm(const MachineInstr *MI) const; 46817fedf216bc10c66e02694854f522cb602097005Chris Lattner 46917fedf216bc10c66e02694854f522cb602097005Chris Lattner //===------------------------------------------------------------------===// 47017fedf216bc10c66e02694854f522cb602097005Chris Lattner // Internal Implementation Details 47117fedf216bc10c66e02694854f522cb602097005Chris Lattner //===------------------------------------------------------------------===// 472dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 47317fedf216bc10c66e02694854f522cb602097005Chris Lattner /// EmitVisibility - This emits visibility information about symbol, if 47417fedf216bc10c66e02694854f522cb602097005Chris Lattner /// this is suported by the target. 4755129bdecd87c518713765acd6998c80f9eef36a2Stuart Hastings void EmitVisibility(MCSymbol *Sym, unsigned Visibility, 4765129bdecd87c518713765acd6998c80f9eef36a2Stuart Hastings bool IsDefinition = true) const; 477dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 47817fedf216bc10c66e02694854f522cb602097005Chris Lattner void EmitLinkage(unsigned Linkage, MCSymbol *GVSym) const; 479dd2ad8432f104282ff43c94457f474ea0a264175Mikhail Glushenkov 48017fedf216bc10c66e02694854f522cb602097005Chris Lattner void EmitJumpTableEntry(const MachineJumpTableInfo *MJTI, 48117fedf216bc10c66e02694854f522cb602097005Chris Lattner const MachineBasicBlock *MBB, 48217fedf216bc10c66e02694854f522cb602097005Chris Lattner unsigned uid) const; 4837d715dfe6d66be257926f626df96a0e2bd38dc1fJay Foad void EmitLLVMUsedList(const Constant *List); 4844a99f59aef358fb93eac180e49f6dcef03822046Anton Korobeynikov void EmitXXStructorList(const Constant *List, bool isCtor); 48517fedf216bc10c66e02694854f522cb602097005Chris Lattner GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy *C); 486a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner }; 487a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner} 488a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner 489a80ba71efe5be5012128e2db0dd29b024e00105aChris Lattner#endif 490