TargetMachine.h revision 98b5795f6227fd31e6cd2852adf5a641ea1ce3be
148486893f46d2e12e926682a3ecb908716bc66c4Chris Lattner//===-- llvm/Target/TargetMachine.h - Target Information --------*- C++ -*-===// 234695381d626485a560594f162701088079589dfMisha Brukman// 36fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// The LLVM Compiler Infrastructure 46fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// 56fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// This file was developed by the LLVM research group and is distributed under 66fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// the University of Illinois Open Source License. See LICENSE.TXT for details. 734695381d626485a560594f162701088079589dfMisha Brukman// 86fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//===----------------------------------------------------------------------===// 9a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve// 101911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner// This file defines the TargetMachine and LLVMTargetMachine classes. 11a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve// 12a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve//===----------------------------------------------------------------------===// 13a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve 14a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve#ifndef LLVM_TARGET_TARGETMACHINE_H 15a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve#define LLVM_TARGET_TARGETMACHINE_H 16a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve 176cee630070b1a7183ed56a8404e812629f5ca538Jim Laskey#include "llvm/Target/TargetInstrItineraries.h" 18a42649e3dd4c8be2d45451429a41f2b13dbeeb78Brian Gaeke#include <cassert> 1907000c6f01d8f57170f2d4c77a86d934bdc5c696Owen Anderson#include <string> 20a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve 21d0fde30ce850b78371fd1386338350591f9ff494Brian Gaekenamespace llvm { 22d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke 23a0f3d17daac73c9c71aad497b298cbe82848f726Jim Laskeyclass TargetAsmInfo; 2407000c6f01d8f57170f2d4c77a86d934bdc5c696Owen Andersonclass TargetData; 25fb5792f416089d8d8d0c6ee62c1f41a55d2cf75dNate Begemanclass TargetSubtarget; 262584ba5867c06e676519d5c7cccbcd59eb7641bcChris Lattnerclass TargetInstrInfo; 272584ba5867c06e676519d5c7cccbcd59eb7641bcChris Lattnerclass TargetInstrDescriptor; 281e60a9165dc4d6ce5650dacc026f2942696af920Chris Lattnerclass TargetJITInfo; 29a84b1c7c4efdba050cbf308eb9ac4fd8392b69d9Evan Chengclass TargetLowering; 305b927c790ed3baa9b555057c9c0904fc34990ba8Chris Lattnerclass TargetFrameInfo; 319f729a30b2e0648209f864da9da8aaa6a4be5e38Chris Lattnerclass MachineCodeEmitter; 32478df7a7ae3c9aaa753948712d894fade36a8195Chris Lattnerclass MRegisterInfo; 3307000c6f01d8f57170f2d4c77a86d934bdc5c696Owen Andersonclass Module; 348844a0ba898a3a1db7f5fd91ecf6a5402e3d51a0Brian Gaekeclass FunctionPassManager; 35b6dcbfc6d1d18e9b3a5dcd0df5f00f7ac3d0100fChris Lattnerclass PassManager; 36ebc7511e8688f2ec23915570377dd4aaf167560eVikram S. Adveclass Pass; 3798b5795f6227fd31e6cd2852adf5a641ea1ce3beBill Wendlingclass TargetMachOWriterInfo; 3898b5795f6227fd31e6cd2852adf5a641ea1ce3beBill Wendlingclass TargetELFWriterInfo; 39a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve 404c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng// Relocation model types. 414c1aa866578f7a358407a22fe55b454f52a24325Evan Chengnamespace Reloc { 424c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng enum Model { 434c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng Default, 444c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng Static, 4535d86fef1f1fc5845366c7c36803a6a3334d8a2eChris Lattner PIC_, // Cannot be named PIC due to collision with -DPIC 464c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng DynamicNoPIC 474c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng }; 484c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng} 494c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng 50152ed053533b26194362994398c0ffad7e1c4109Evan Cheng// Code model types. 51152ed053533b26194362994398c0ffad7e1c4109Evan Chengnamespace CodeModel { 52152ed053533b26194362994398c0ffad7e1c4109Evan Cheng enum Model { 53152ed053533b26194362994398c0ffad7e1c4109Evan Cheng Default, 54152ed053533b26194362994398c0ffad7e1c4109Evan Cheng Small, 55152ed053533b26194362994398c0ffad7e1c4109Evan Cheng Kernel, 56152ed053533b26194362994398c0ffad7e1c4109Evan Cheng Medium, 57152ed053533b26194362994398c0ffad7e1c4109Evan Cheng Large 58152ed053533b26194362994398c0ffad7e1c4109Evan Cheng }; 59152ed053533b26194362994398c0ffad7e1c4109Evan Cheng} 60152ed053533b26194362994398c0ffad7e1c4109Evan Cheng 615b927c790ed3baa9b555057c9c0904fc34990ba8Chris Lattner//===----------------------------------------------------------------------===// 625b927c790ed3baa9b555057c9c0904fc34990ba8Chris Lattner/// 635b927c790ed3baa9b555057c9c0904fc34990ba8Chris Lattner/// TargetMachine - Primary interface to the complete machine description for 645b927c790ed3baa9b555057c9c0904fc34990ba8Chris Lattner/// the target machine. All target-specific information should be accessible 655b927c790ed3baa9b555057c9c0904fc34990ba8Chris Lattner/// through this interface. 6634695381d626485a560594f162701088079589dfMisha Brukman/// 6717035c0edf5463fd9edb8496502f4c5a0dc1d7abChris Lattnerclass TargetMachine { 681911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner TargetMachine(const TargetMachine &); // DO NOT IMPLEMENT 691911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner void operator=(const TargetMachine &); // DO NOT IMPLEMENT 7007ac914973ebb484dd7ed1ad143934e14ad56e26Chris Lattnerprotected: // Can only create subclasses. 71e911615c4769d793588087b5321d303ecb9661c7Bill Wendling TargetMachine() : AsmInfo(NULL) { } 728d2623d49a7b53f2bb25f2b61c14aecb91e19154Nate Begeman 738d2623d49a7b53f2bb25f2b61c14aecb91e19154Nate Begeman /// getSubtargetImpl - virtual method implemented by subclasses that returns 748d2623d49a7b53f2bb25f2b61c14aecb91e19154Nate Begeman /// a reference to that target's TargetSubtarget-derived member variable. 758d2623d49a7b53f2bb25f2b61c14aecb91e19154Nate Begeman virtual const TargetSubtarget *getSubtargetImpl() const { return 0; } 76a0f3d17daac73c9c71aad497b298cbe82848f726Jim Laskey 77a0f3d17daac73c9c71aad497b298cbe82848f726Jim Laskey /// AsmInfo - Contains target specific asm information. 78a0f3d17daac73c9c71aad497b298cbe82848f726Jim Laskey /// 79a0f3d17daac73c9c71aad497b298cbe82848f726Jim Laskey mutable const TargetAsmInfo *AsmInfo; 80e911615c4769d793588087b5321d303ecb9661c7Bill Wendling 81fde1b3bb2f15b74c713d98a79fcddaff1ac00dd1Jim Laskey /// createTargetAsmInfo - Create a new instance of target specific asm 82fde1b3bb2f15b74c713d98a79fcddaff1ac00dd1Jim Laskey /// information. 83fde1b3bb2f15b74c713d98a79fcddaff1ac00dd1Jim Laskey virtual const TargetAsmInfo *createTargetAsmInfo() const { return NULL; } 84fde1b3bb2f15b74c713d98a79fcddaff1ac00dd1Jim Laskey 85a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Advepublic: 86f70e0c216c074bd2ae2b08178f5512849545db4eChris Lattner virtual ~TargetMachine(); 876334205cb5c626d2b35e42dd4c710b857bf0a126Chris Lattner 88a51e273a764b2a3e8fe856c3bd47b09f9446f380Chris Lattner /// getModuleMatchQuality - This static method should be implemented by 89a51e273a764b2a3e8fe856c3bd47b09f9446f380Chris Lattner /// targets to indicate how closely they match the specified module. This is 90a51e273a764b2a3e8fe856c3bd47b09f9446f380Chris Lattner /// used by the LLC tool to determine which target to use when an explicit 91a51e273a764b2a3e8fe856c3bd47b09f9446f380Chris Lattner /// -march option is not specified. If a target returns zero, it will never 92a51e273a764b2a3e8fe856c3bd47b09f9446f380Chris Lattner /// be chosen without an explicit -march option. 93a51e273a764b2a3e8fe856c3bd47b09f9446f380Chris Lattner static unsigned getModuleMatchQuality(const Module &M) { return 0; } 94a51e273a764b2a3e8fe856c3bd47b09f9446f380Chris Lattner 95a51e273a764b2a3e8fe856c3bd47b09f9446f380Chris Lattner /// getJITMatchQuality - This static method should be implemented by targets 96a51e273a764b2a3e8fe856c3bd47b09f9446f380Chris Lattner /// that provide JIT capabilities to indicate how suitable they are for 97a51e273a764b2a3e8fe856c3bd47b09f9446f380Chris Lattner /// execution on the current host. If a value of 0 is returned, the target 98a51e273a764b2a3e8fe856c3bd47b09f9446f380Chris Lattner /// will not be used unless an explicit -march option is used. 99a51e273a764b2a3e8fe856c3bd47b09f9446f380Chris Lattner static unsigned getJITMatchQuality() { return 0; } 100a51e273a764b2a3e8fe856c3bd47b09f9446f380Chris Lattner 101a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve // Interfaces to the major aspects of target machine information: 102a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve // -- Instruction opcode and operand information 103a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve // -- Pipelines and scheduling information 104d55697cf136150b697b9bbddce9088e87a1be963Vikram S. Adve // -- Stack frame information 105a84b1c7c4efdba050cbf308eb9ac4fd8392b69d9Evan Cheng // -- Selection DAG lowering information 10634695381d626485a560594f162701088079589dfMisha Brukman // 10736c2a0593509da714bea6457dd1b00a7417ce342Chris Lattner virtual const TargetInstrInfo *getInstrInfo() const { return 0; } 10836c2a0593509da714bea6457dd1b00a7417ce342Chris Lattner virtual const TargetFrameInfo *getFrameInfo() const { return 0; } 109a84b1c7c4efdba050cbf308eb9ac4fd8392b69d9Evan Cheng virtual TargetLowering *getTargetLowering() const { return 0; } 110a69571c7991813c93cba64e88eced6899ce93d81Owen Anderson virtual const TargetData *getTargetData() const { return 0; } 111a0f3d17daac73c9c71aad497b298cbe82848f726Jim Laskey 112e911615c4769d793588087b5321d303ecb9661c7Bill Wendling 113a0f3d17daac73c9c71aad497b298cbe82848f726Jim Laskey /// getTargetAsmInfo - Return target specific asm information. 114a0f3d17daac73c9c71aad497b298cbe82848f726Jim Laskey /// 115a0f3d17daac73c9c71aad497b298cbe82848f726Jim Laskey const TargetAsmInfo *getTargetAsmInfo() const { 116a0f3d17daac73c9c71aad497b298cbe82848f726Jim Laskey if (!AsmInfo) AsmInfo = createTargetAsmInfo(); 117a0f3d17daac73c9c71aad497b298cbe82848f726Jim Laskey return AsmInfo; 118a0f3d17daac73c9c71aad497b298cbe82848f726Jim Laskey } 119a0f3d17daac73c9c71aad497b298cbe82848f726Jim Laskey 1209eb59ec548b861d6ede05b4e6dc22aabf645e665Jeff Cohen /// getSubtarget - This method returns a pointer to the specified type of 1218d2623d49a7b53f2bb25f2b61c14aecb91e19154Nate Begeman /// TargetSubtarget. In debug builds, it verifies that the object being 1228d2623d49a7b53f2bb25f2b61c14aecb91e19154Nate Begeman /// returned is of the correct type. 1235ab83632066071413841af43bc5d1edcced18076Chris Lattner template<typename STC> const STC &getSubtarget() const { 1248d2623d49a7b53f2bb25f2b61c14aecb91e19154Nate Begeman const TargetSubtarget *TST = getSubtargetImpl(); 1255ab83632066071413841af43bc5d1edcced18076Chris Lattner assert(TST && dynamic_cast<const STC*>(TST) && 126fb5792f416089d8d8d0c6ee62c1f41a55d2cf75dNate Begeman "Not the right kind of subtarget!"); 1275ab83632066071413841af43bc5d1edcced18076Chris Lattner return *static_cast<const STC*>(TST); 128fb5792f416089d8d8d0c6ee62c1f41a55d2cf75dNate Begeman } 129fb5792f416089d8d8d0c6ee62c1f41a55d2cf75dNate Begeman 130478df7a7ae3c9aaa753948712d894fade36a8195Chris Lattner /// getRegisterInfo - If register information is available, return it. If 1315b927c790ed3baa9b555057c9c0904fc34990ba8Chris Lattner /// not, return null. This is kept separate from RegInfo until RegInfo has 1325b927c790ed3baa9b555057c9c0904fc34990ba8Chris Lattner /// details of graph coloring register allocation removed from it. 133478df7a7ae3c9aaa753948712d894fade36a8195Chris Lattner /// 13407ac914973ebb484dd7ed1ad143934e14ad56e26Chris Lattner virtual const MRegisterInfo *getRegisterInfo() const { return 0; } 135478df7a7ae3c9aaa753948712d894fade36a8195Chris Lattner 1361e60a9165dc4d6ce5650dacc026f2942696af920Chris Lattner /// getJITInfo - If this target supports a JIT, return information for it, 1371e60a9165dc4d6ce5650dacc026f2942696af920Chris Lattner /// otherwise return null. 1381e60a9165dc4d6ce5650dacc026f2942696af920Chris Lattner /// 1391e60a9165dc4d6ce5650dacc026f2942696af920Chris Lattner virtual TargetJITInfo *getJITInfo() { return 0; } 1406cee630070b1a7183ed56a8404e812629f5ca538Jim Laskey 1416cee630070b1a7183ed56a8404e812629f5ca538Jim Laskey /// getInstrItineraryData - Returns instruction itinerary data for the target 1426cee630070b1a7183ed56a8404e812629f5ca538Jim Laskey /// or specific subtarget. 1436cee630070b1a7183ed56a8404e812629f5ca538Jim Laskey /// 1446cee630070b1a7183ed56a8404e812629f5ca538Jim Laskey virtual const InstrItineraryData getInstrItineraryData() const { 1456cee630070b1a7183ed56a8404e812629f5ca538Jim Laskey return InstrItineraryData(); 1466cee630070b1a7183ed56a8404e812629f5ca538Jim Laskey } 1471e60a9165dc4d6ce5650dacc026f2942696af920Chris Lattner 1488f5159e6b225356bd9c07c7040bab002b8707c0aBill Wendling /// getMachOWriterInfo - If this target supports a Mach-O writer, return 1498f5159e6b225356bd9c07c7040bab002b8707c0aBill Wendling /// information for it, otherwise return null. 1508f5159e6b225356bd9c07c7040bab002b8707c0aBill Wendling /// 1518f5159e6b225356bd9c07c7040bab002b8707c0aBill Wendling virtual const TargetMachOWriterInfo *getMachOWriterInfo() const { return 0; } 1528f5159e6b225356bd9c07c7040bab002b8707c0aBill Wendling 15398b5795f6227fd31e6cd2852adf5a641ea1ce3beBill Wendling /// getELFWriterInfo - If this target supports an ELF writer, return 15498b5795f6227fd31e6cd2852adf5a641ea1ce3beBill Wendling /// information for it, otherwise return null. 15598b5795f6227fd31e6cd2852adf5a641ea1ce3beBill Wendling /// 15698b5795f6227fd31e6cd2852adf5a641ea1ce3beBill Wendling virtual const TargetELFWriterInfo *getELFWriterInfo() const { return 0; } 15798b5795f6227fd31e6cd2852adf5a641ea1ce3beBill Wendling 1584c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng /// getRelocationModel - Returns the code generation relocation model. The 1594c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng /// choices are static, PIC, and dynamic-no-pic, and target default. 1604c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng static Reloc::Model getRelocationModel(); 1614c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng 1624c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng /// setRelocationModel - Sets the code generation relocation model. 1634c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng static void setRelocationModel(Reloc::Model Model); 1644c1aa866578f7a358407a22fe55b454f52a24325Evan Cheng 165152ed053533b26194362994398c0ffad7e1c4109Evan Cheng /// getCodeModel - Returns the code model. The choices are small, kernel, 166152ed053533b26194362994398c0ffad7e1c4109Evan Cheng /// medium, large, and target default. 167152ed053533b26194362994398c0ffad7e1c4109Evan Cheng static CodeModel::Model getCodeModel(); 168152ed053533b26194362994398c0ffad7e1c4109Evan Cheng 169152ed053533b26194362994398c0ffad7e1c4109Evan Cheng /// setCodeModel - Sets the code model. 170152ed053533b26194362994398c0ffad7e1c4109Evan Cheng static void setCodeModel(CodeModel::Model Model); 171152ed053533b26194362994398c0ffad7e1c4109Evan Cheng 17211f14c8be0946a8fb95189156ff1d64a01ff7da3Chris Lattner /// CodeGenFileType - These enums are meant to be passed into 17311f14c8be0946a8fb95189156ff1d64a01ff7da3Chris Lattner /// addPassesToEmitFile to indicate what type of file to emit. 17411f14c8be0946a8fb95189156ff1d64a01ff7da3Chris Lattner enum CodeGenFileType { 17533f80a87230f61b85f62cbc956b6f521b6e2063cChris Lattner AssemblyFile, ObjectFile, DynamicLibrary 17611f14c8be0946a8fb95189156ff1d64a01ff7da3Chris Lattner }; 17711f14c8be0946a8fb95189156ff1d64a01ff7da3Chris Lattner 17811f14c8be0946a8fb95189156ff1d64a01ff7da3Chris Lattner /// addPassesToEmitFile - Add passes to the specified pass manager to get 17911f14c8be0946a8fb95189156ff1d64a01ff7da3Chris Lattner /// the specified file emitted. Typically this will involve several steps of 180df2e425f2a3b64eb17be927539cd39cb1f1c5f77Chris Lattner /// code generation. If Fast is set to true, the code generator should emit 181df2e425f2a3b64eb17be927539cd39cb1f1c5f77Chris Lattner /// code as fast as possible, without regard for compile time. This method 182df2e425f2a3b64eb17be927539cd39cb1f1c5f77Chris Lattner /// should return true if emission of this file type is not supported. 183ebb1af16bea8f163cbb74c55ae41885c396f72cbChris Lattner /// 1841911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner virtual bool addPassesToEmitFile(FunctionPassManager &PM, std::ostream &Out, 185df2e425f2a3b64eb17be927539cd39cb1f1c5f77Chris Lattner CodeGenFileType FileType, bool Fast) { 1866334205cb5c626d2b35e42dd4c710b857bf0a126Chris Lattner return true; 1876334205cb5c626d2b35e42dd4c710b857bf0a126Chris Lattner } 1881911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner 1891911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// addPassesToEmitMachineCode - Add passes to the specified pass manager to 1901911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// get machine code emitted. This uses a MachineCodeEmitter object to handle 1911911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// actually outputting the machine code and resolving things like the address 1921911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// of functions. This method returns true if machine code emission is 1931911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// not supported. 1941911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// 1951911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM, 1961911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner MachineCodeEmitter &MCE, bool Fast) { 1971911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner return true; 1981911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner } 1991911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner 200ebc7511e8688f2ec23915570377dd4aaf167560eVikram S. Adve 2011911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// addPassesToEmitWholeFile - This method can be implemented by targets that 2021911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// require having the entire module at once. This is not recommended, do not 2031911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// use this. 2041911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner virtual bool WantsWholeFile() const { return false; } 2051911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner virtual bool addPassesToEmitWholeFile(PassManager &PM, std::ostream &Out, 2061911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner CodeGenFileType FileType, bool Fast) { 2071911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner return true; 2081911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner } 2091911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner}; 2101911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner 2111911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner/// LLVMTargetMachine - This class describes a target machine that is 2121911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner/// implemented with the LLVM target-independent code generator. 2131911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner/// 2141911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattnerclass LLVMTargetMachine : public TargetMachine { 2151911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattnerprotected: // Can only create subclasses. 2161911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner LLVMTargetMachine() { } 2171911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattnerpublic: 2181911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner 2191911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// addPassesToEmitFile - Add passes to the specified pass manager to get 2201911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// the specified file emitted. Typically this will involve several steps of 2211911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// code generation. If Fast is set to true, the code generator should emit 2221911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// code as fast as possible, without regard for compile time. This method 2231911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// should return true if emission of this file type is not supported. 2241911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// 2251911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// The default implementation of this method adds components from the 2261911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// LLVM retargetable code generator, invoking the methods below to get 2271911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// target-specific passes in standard locations. 2281911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// 2291911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner virtual bool addPassesToEmitFile(FunctionPassManager &PM, std::ostream &Out, 2301911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner CodeGenFileType FileType, bool Fast); 2311911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner 2329f729a30b2e0648209f864da9da8aaa6a4be5e38Chris Lattner /// addPassesToEmitMachineCode - Add passes to the specified pass manager to 2338844a0ba898a3a1db7f5fd91ecf6a5402e3d51a0Brian Gaeke /// get machine code emitted. This uses a MachineCodeEmitter object to handle 2349f729a30b2e0648209f864da9da8aaa6a4be5e38Chris Lattner /// actually outputting the machine code and resolving things like the address 2351911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// of functions. This method returns true if machine code emission is 236b7a2d2256fede467c7f50444eb3cddadcd7d34c9Chris Lattner /// not supported. 2375c1b5244b956a28667bc2a9e7a84fa39697ba715Chris Lattner /// 2388844a0ba898a3a1db7f5fd91ecf6a5402e3d51a0Brian Gaeke virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM, 2391911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner MachineCodeEmitter &MCE, bool Fast); 2401911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner 2411911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// Target-Independent Code Generator Pass Configuration Options. 2421911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner 2431911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// addInstSelector - This method should add any "last minute" LLVM->LLVM 2441911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// passes, then install an instruction selector pass, which converts from 2451911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// LLVM code to machine instructions. 2461911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner virtual bool addInstSelector(FunctionPassManager &PM, bool Fast) { 2471911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner return true; 2481911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner } 2491911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner 2501911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// addPostRegAllocPasses - This method may be implemented by targets that 2511911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// want to run passes after register allocation but before prolog-epilog 2521911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// insertion. This should return true if -print-machineinstrs should print 2531911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// after these passes. 2541911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner virtual bool addPostRegAlloc(FunctionPassManager &PM, bool Fast) { 2551911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner return false; 2561911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner } 2571911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner 2581911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// addPreEmitPass - This pass may be implemented by targets that want to run 2591911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// passes immediately before machine code is emitted. This should return 2601911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// true if -print-machineinstrs should print out the code after the passes. 2611911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner virtual bool addPreEmitPass(FunctionPassManager &PM, bool Fast) { 2621911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner return false; 2631911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner } 2641911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner 2651911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner 2661911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// addAssemblyEmitter - This pass should be overridden by the target to add 2671911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// the asmprinter, if asm emission is supported. If this is not supported, 2681911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// 'true' should be returned. 2691911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner virtual bool addAssemblyEmitter(FunctionPassManager &PM, bool Fast, 2701911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner std::ostream &Out) { 2711911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner return true; 2721911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner } 2731911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner 2741911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// addObjectWriter - This pass should be overridden by the target to add 2751911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// the object-file writer, if supported. If this is not supported, 2761911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// 'true' should be returned. 2771911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner virtual bool addObjectWriter(FunctionPassManager &PM, bool Fast, 2781911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner std::ostream &Out) { 2791911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner return true; 2801911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner } 2811911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner 2821911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// addCodeEmitter - This pass should be overridden by the target to add a 2831911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// code emitter, if supported. If this is not supported, 'true' should be 2841911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner /// returned. 2851911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner virtual bool addCodeEmitter(FunctionPassManager &PM, bool Fast, 2861911fd4f85aebcd4d7b8f27313c5a363eebf49cbChris Lattner MachineCodeEmitter &MCE) { 2879f729a30b2e0648209f864da9da8aaa6a4be5e38Chris Lattner return true; 2889f729a30b2e0648209f864da9da8aaa6a4be5e38Chris Lattner } 289a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve}; 290a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve 291d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke} // End llvm namespace 292d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke 293a578a6d054e8219c730840700d8d5fd29f15a962Vikram S. Adve#endif 294