TargetLowering.h revision bcc5f36765e8111c13873a0c0dc874c92385d808
1457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner//===-- llvm/Target/TargetLowering.h - Target Lowering Info -----*- C++ -*-===// 2457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// 3457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// The LLVM Compiler Infrastructure 4457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// 5457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// This file was developed by the LLVM research group and is distributed under 6457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// the University of Illinois Open Source License. See LICENSE.TXT for details. 7457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// 8457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner//===----------------------------------------------------------------------===// 9457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// 10457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// This file describes how to lower LLVM code to machine code. This has two 11457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// main components: 12457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// 13457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// 1. Which ValueTypes are natively supported by the target. 14457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// 2. Which operations are supported for supported ValueTypes. 15457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// 3. Cost thresholds for alternative implementations of certain operations. 1692b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner// 17a8dfb79e6f9311ddb6b9869fb20bef3c99fdfb24Daniel Dunbar// In addition it has a few other components, like information about FP 18457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner// immediates. 194a2e5edb94c5d6ceb2f8f99ec031963e4c3862f9Chris Lattner// 2092b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner//===----------------------------------------------------------------------===// 2192b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner 22457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner#ifndef LLVM_TARGET_TARGETLOWERING_H 23457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner#define LLVM_TARGET_TARGETLOWERING_H 24457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner 25457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner#include "llvm/CodeGen/SelectionDAGNodes.h" 268c8b9ee8c8646aa1a79c782d4da9abdf3eb4eefeArgyrios Kyrtzidis#include "llvm/CodeGen/RuntimeLibcalls.h" 278c8b9ee8c8646aa1a79c782d4da9abdf3eb4eefeArgyrios Kyrtzidis#include <map> 2892b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner#include <vector> 2992b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner 304a2e5edb94c5d6ceb2f8f99ec031963e4c3862f9Chris Lattnernamespace llvm { 311ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner class Value; 32457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner class Function; 3396716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes class TargetMachine; 344a2e5edb94c5d6ceb2f8f99ec031963e4c3862f9Chris Lattner class TargetData; 3500cb3fe786855ce6545234bc3430223eb9272206Chris Lattner class TargetRegisterClass; 36457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner class SDNode; 37457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner class SDOperand; 38457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner class SelectionDAG; 3973c557458c0e28899f37c557bcaf36c2b6701260Daniel Dunbar class MachineBasicBlock; 4073c557458c0e28899f37c557bcaf36c2b6701260Daniel Dunbar class MachineInstr; 41a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindola class PackedType; 4273c557458c0e28899f37c557bcaf36c2b6701260Daniel Dunbar 4373c557458c0e28899f37c557bcaf36c2b6701260Daniel Dunbar//===----------------------------------------------------------------------===// 448d31de62680f28ac13594a14dde46216c82a3708Chris Lattner/// TargetLowering - This class defines information used to lower LLVM code to 458d31de62680f28ac13594a14dde46216c82a3708Chris Lattner/// legal SelectionDAG operators that the target instruction selector can accept 46b36052f0e4f59525b34bb4b56648c9121a8beda8Daniel Dunbar/// natively. 47b36052f0e4f59525b34bb4b56648c9121a8beda8Daniel Dunbar/// 489fc05227a2596c545b845ed9a72673995e49d16bChris Lattner/// This class also defines callbacks that targets must implement to lower 49b36052f0e4f59525b34bb4b56648c9121a8beda8Daniel Dunbar/// target-specific constructs to SelectionDAG operators. 50a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindola/// 51a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindolaclass TargetLowering { 5273c557458c0e28899f37c557bcaf36c2b6701260Daniel Dunbarpublic: 5396716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// LegalizeAction - This enum indicates whether operations are valid for a 548d31de62680f28ac13594a14dde46216c82a3708Chris Lattner /// target, and if not, what action should be used to make them valid. 558d31de62680f28ac13594a14dde46216c82a3708Chris Lattner enum LegalizeAction { 5673c557458c0e28899f37c557bcaf36c2b6701260Daniel Dunbar Legal, // The target natively supports this operation. 578d31de62680f28ac13594a14dde46216c82a3708Chris Lattner Promote, // This operation should be executed in a larger type. 5873c557458c0e28899f37c557bcaf36c2b6701260Daniel Dunbar Expand, // Try to expand this to other ops, otherwise use a libcall. 5973c557458c0e28899f37c557bcaf36c2b6701260Daniel Dunbar Custom // Use the LowerOperation hook to implement custom lowering. 6073c557458c0e28899f37c557bcaf36c2b6701260Daniel Dunbar }; 6196716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes 6228249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner enum OutOfRangeShiftAmount { 6328249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner Undefined, // Oversized shift amounts are undefined (default). 6428249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner Mask, // Shift amounts are auto masked (anded) to value size. 655a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes Extend // Oversized shift pulls in zeros or sign bits. 665a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes }; 675a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes 685a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes enum SetCCResultValue { 695a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes UndefinedSetCCResult, // SetCC returns a garbage/unknown extend. 705a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes ZeroOrOneSetCCResult, // SetCC returns a zero extended result. 715a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes ZeroOrNegativeOneSetCCResult // SetCC returns a sign extended result. 725a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes }; 735a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes 745a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes enum SchedPreference { 755a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes SchedulingForLatency, // Scheduling for shortest total latency. 765a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes SchedulingForRegPressure // Scheduling for lowest register pressure. 775a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes }; 785a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes 79e86b01c153ba52307ecb6e7513ec33f57caedfddBruno Cardoso Lopes TargetLowering(TargetMachine &TM); 80e86b01c153ba52307ecb6e7513ec33f57caedfddBruno Cardoso Lopes virtual ~TargetLowering(); 815a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes 8296716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes TargetMachine &getTargetMachine() const { return TM; } 835a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes const TargetData *getTargetData() const { return TD; } 845a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes 855a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes bool isLittleEndian() const { return IsLittleEndian; } 865a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes MVT::ValueType getPointerTy() const { return PointerTy; } 8796716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes MVT::ValueType getShiftAmountTy() const { return ShiftAmountTy; } 8837ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner OutOfRangeShiftAmount getShiftAmountFlavor() const {return ShiftAmtHandling; } 8992b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner 9037ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// usesGlobalOffsetTable - Return true if this target uses a GOT for PIC 91457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner /// codegen. 9296716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes bool usesGlobalOffsetTable() const { return UsesGlobalOffsetTable; } 9337ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner 9437ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// isSelectExpensive - Return true if the select operation is expensive for 9528249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// this target. 9628249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner bool isSelectExpensive() const { return SelectIsExpensive; } 9737ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner 9828249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// isIntDivCheap() - Return true if integer divide is usually cheaper than 9928249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// a sequence of several shifts, adds, and multiplies for this target. 10028249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner bool isIntDivCheap() const { return IntDivIsCheap; } 1010e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner 10296716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// isPow2DivCheap() - Return true if pow2 div is cheaper than a chain of 103cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner /// srl/add/sra. 104a38c707d8219a29f50564c826d2aa3154e214c66Chris Lattner bool isPow2DivCheap() const { return Pow2DivIsCheap; } 105835acabce13993e210b7cef0020a585125f9cb1eChris Lattner 106835acabce13993e210b7cef0020a585125f9cb1eChris Lattner /// getSetCCResultTy - Return the ValueType of the result of setcc operations. 10796716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// 10828249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner MVT::ValueType getSetCCResultTy() const { return SetCCResultTy; } 10928249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner 11028249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// getSetCCResultContents - For targets without boolean registers, this flag 11128249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// returns information about the contents of the high-bits in the setcc 11228249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// result register. 11396716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes SetCCResultValue getSetCCResultContents() const { return SetCCResultContents;} 11428249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner 11537ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// getSchedulingPreference - Return target scheduling preference. 11637ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner SchedPreference getSchedulingPreference() const { 11728249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner return SchedPreferenceInfo; 11896716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes } 1190e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner 12037ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// getRegClassFor - Return the register class that should be used for the 12137ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// specified value type. This may only be called on legal types. 12237ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner TargetRegisterClass *getRegClassFor(MVT::ValueType VT) const { 1230e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner TargetRegisterClass *RC = RegClassForVT[VT]; 12496716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes assert(RC && "This value type is not natively supported!"); 12596716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes return RC; 1261ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner } 12796716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes 12899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// isTypeLegal - Return true if the target has native support for the 1295dccfadbf4f46a0a06240f3591f7500e75b1d8cdChris Lattner /// specified value type. This means that it has a register that directly 13096716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// holds it without promotions or expansions. 13173c557458c0e28899f37c557bcaf36c2b6701260Daniel Dunbar bool isTypeLegal(MVT::ValueType VT) const { 13273c557458c0e28899f37c557bcaf36c2b6701260Daniel Dunbar return RegClassForVT[VT] != 0; 13396716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes } 1341cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes 13599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes class ValueTypeActionImpl { 13699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// ValueTypeActions - This is a bitvector that contains two bits for each 13799405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// value type, where the two bits correspond to the LegalizeAction enum. 1381cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes /// This can be queried with "getTypeAction(VT)". 1391cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes uint32_t ValueTypeActions[2]; 1401cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes public: 1411cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes ValueTypeActionImpl() { 142834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner ValueTypeActions[0] = ValueTypeActions[1] = 0; 14399405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes } 14499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes ValueTypeActionImpl(const ValueTypeActionImpl &RHS) { 145457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner ValueTypeActions[0] = RHS.ValueTypeActions[0]; 146457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner ValueTypeActions[1] = RHS.ValueTypeActions[1]; 147457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner } 148457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner 149457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner LegalizeAction getTypeAction(MVT::ValueType VT) const { 15000cb3fe786855ce6545234bc3430223eb9272206Chris Lattner return (LegalizeAction)((ValueTypeActions[VT>>4] >> ((2*VT) & 31)) & 3); 15186020e46289643de2f8c7603b550ffc8b6aff376Chris Lattner } 15286020e46289643de2f8c7603b550ffc8b6aff376Chris Lattner void setTypeAction(MVT::ValueType VT, LegalizeAction Action) { 1534a2e5edb94c5d6ceb2f8f99ec031963e4c3862f9Chris Lattner assert(unsigned(VT >> 4) < 15400cb3fe786855ce6545234bc3430223eb9272206Chris Lattner sizeof(ValueTypeActions)/sizeof(ValueTypeActions[0])); 15500cb3fe786855ce6545234bc3430223eb9272206Chris Lattner ValueTypeActions[VT>>4] |= Action << ((VT*2) & 31); 15600cb3fe786855ce6545234bc3430223eb9272206Chris Lattner } 15786020e46289643de2f8c7603b550ffc8b6aff376Chris Lattner }; 15886020e46289643de2f8c7603b550ffc8b6aff376Chris Lattner 1594a2e5edb94c5d6ceb2f8f99ec031963e4c3862f9Chris Lattner const ValueTypeActionImpl &getValueTypeActions() const { 16092b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner return ValueTypeActions; 16192b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner } 16296716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes 16396716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// getTypeAction - Return how we should legalize values of this type, either 1641ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner /// it is already legal (return 'Legal') or we need to promote it to a larger 1651ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner /// type (return 'Promote'), or we need to expand it into multiple registers 1661ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner /// of smaller integer type (return 'Expand'). 'Custom' is not an option. 1671ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner LegalizeAction getTypeAction(MVT::ValueType VT) const { 168cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner return ValueTypeActions.getTypeAction(VT); 169cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner } 17099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 171cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner /// getTypeToTransformTo - For types supported by the target, this is an 172cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner /// identity function. For types that must be promoted to larger types, this 17396716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// returns the larger type to promote to. For integer types that are larger 174cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner /// than the largest integer register, this contains one step in the expansion 175cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner /// to get to the smaller register. For illegal floating point types, this 176cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner /// returns the integer type to transform to. 1779fc05227a2596c545b845ed9a72673995e49d16bChris Lattner MVT::ValueType getTypeToTransformTo(MVT::ValueType VT) const { 178cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner return TransformToType[VT]; 179cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner } 180cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner 181cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner /// getTypeToExpandTo - For types supported by the target, this is an 182cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner /// identity function. For types that must be expanded (i.e. integer types 1838a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner /// that are larger than the largest integer register or illegal floating 1848a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner /// point types), this returns the largest legal type it will be expanded to. 1858a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner MVT::ValueType getTypeToExpandTo(MVT::ValueType VT) const { 1868a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner while (true) { 1878a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner switch (getTypeAction(VT)) { 1888a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner case Legal: 1898a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner return VT; 1908892b033e4c8d25403f10ad3977a8905ec4c5029Nick Lewycky case Expand: 1918892b033e4c8d25403f10ad3977a8905ec4c5029Nick Lewycky VT = TransformToType[VT]; 1928a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner break; 1938a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner default: 1948a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner assert(false && "Type is not legal nor is it to be expanded!"); 195cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner return VT; 1960e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner } 197cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner } 198a38c707d8219a29f50564c826d2aa3154e214c66Chris Lattner return VT; 199835acabce13993e210b7cef0020a585125f9cb1eChris Lattner } 2000e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner 2010e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// getPackedTypeBreakdown - Packed types are broken down into some number of 2028496a26113859288730d0d97637d032de53b2a7eChris Lattner /// legal first class types. For example, <8 x float> maps to 2 MVT::v4f32 203a08b587494a09a94a72245dd9d7088564e511f4eChris Lattner /// with Altivec or SSE1, or 8 promoted MVT::f64 values with the X86 FP stack. 204a08b587494a09a94a72245dd9d7088564e511f4eChris Lattner /// Similarly, <2 x long> turns into 4 MVT::i32 values with both PPC and X86. 205835acabce13993e210b7cef0020a585125f9cb1eChris Lattner /// 2060e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// This method returns the number of registers needed, and the VT for each 2070e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// register. It also returns the VT of the PackedType elements before they 20837ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// are promoted/expanded. 209835acabce13993e210b7cef0020a585125f9cb1eChris Lattner /// 210835acabce13993e210b7cef0020a585125f9cb1eChris Lattner unsigned getPackedTypeBreakdown(const PackedType *PTy, 21196716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes MVT::ValueType &PTyElementVT, 212a08b587494a09a94a72245dd9d7088564e511f4eChris Lattner MVT::ValueType &PTyLegalElementVT) const; 213a08b587494a09a94a72245dd9d7088564e511f4eChris Lattner 214a08b587494a09a94a72245dd9d7088564e511f4eChris Lattner typedef std::vector<double>::const_iterator legal_fpimm_iterator; 2159fdac902d4300f2b0b8f4830ff276cc8199864b5Daniel Dunbar legal_fpimm_iterator legal_fpimm_begin() const { 2169fdac902d4300f2b0b8f4830ff276cc8199864b5Daniel Dunbar return LegalFPImmediates.begin(); 217a08b587494a09a94a72245dd9d7088564e511f4eChris Lattner } 2189fc05227a2596c545b845ed9a72673995e49d16bChris Lattner legal_fpimm_iterator legal_fpimm_end() const { 219da3051a17f586b069951931eeed9317cad41243bChris Lattner return LegalFPImmediates.end(); 220a08b587494a09a94a72245dd9d7088564e511f4eChris Lattner } 221a08b587494a09a94a72245dd9d7088564e511f4eChris Lattner 22296716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// isShuffleMaskLegal - Targets can use this to indicate that they only 2234a2e5edb94c5d6ceb2f8f99ec031963e4c3862f9Chris Lattner /// support *some* VECTOR_SHUFFLE operations, those with specific masks. 224a08b587494a09a94a72245dd9d7088564e511f4eChris Lattner /// By default, if a target supports the VECTOR_SHUFFLE node, all mask values 2254a2e5edb94c5d6ceb2f8f99ec031963e4c3862f9Chris Lattner /// are assumed to be legal. 22696716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes virtual bool isShuffleMaskLegal(SDOperand Mask, MVT::ValueType VT) const { 2275dccfadbf4f46a0a06240f3591f7500e75b1d8cdChris Lattner return true; 228835acabce13993e210b7cef0020a585125f9cb1eChris Lattner } 229a38c707d8219a29f50564c826d2aa3154e214c66Chris Lattner 2300e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// isVectorClearMaskLegal - Similar to isShuffleMaskLegal. This is 2310e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// used by Targets can use this to indicate if there is a suitable 2321ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner /// VECTOR_SHUFFLE that can be used to replace a VAND with a constant 2331ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner /// pool entry. 23499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes virtual bool isVectorClearMaskLegal(std::vector<SDOperand> &BVOps, 2355dccfadbf4f46a0a06240f3591f7500e75b1d8cdChris Lattner MVT::ValueType EVT, 2365dccfadbf4f46a0a06240f3591f7500e75b1d8cdChris Lattner SelectionDAG &DAG) const { 2378a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner return false; 2388a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner } 2398a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner 2408a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner /// getOperationAction - Return how this operation should be treated: either 2411ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner /// it is legal, needs to be promoted to a larger size, needs to be 24296716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// expanded to some other code sequence, or the target has a custom expander 2431e35d0e9234836c4cea5ec9d1ec11dcc017911beChris Lattner /// for it. 2441e35d0e9234836c4cea5ec9d1ec11dcc017911beChris Lattner LegalizeAction getOperationAction(unsigned Op, MVT::ValueType VT) const { 245497f1eb2b89721e81b65237df90d23cb60de16b0Eric Christopher return (LegalizeAction)((OpActions[Op] >> (2*VT)) & 3); 246497f1eb2b89721e81b65237df90d23cb60de16b0Eric Christopher } 2471e35d0e9234836c4cea5ec9d1ec11dcc017911beChris Lattner 24896716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// isOperationLegal - Return true if the specified operation is legal on this 2490f53cf22361d89690dcf58409decb43d2a3ad60fChris Lattner /// target. 25096716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes bool isOperationLegal(unsigned Op, MVT::ValueType VT) const { 2510f53cf22361d89690dcf58409decb43d2a3ad60fChris Lattner return getOperationAction(Op, VT) == Legal || 2520f53cf22361d89690dcf58409decb43d2a3ad60fChris Lattner getOperationAction(Op, VT) == Custom; 2530f53cf22361d89690dcf58409decb43d2a3ad60fChris Lattner } 2549fdac902d4300f2b0b8f4830ff276cc8199864b5Daniel Dunbar 2559fdac902d4300f2b0b8f4830ff276cc8199864b5Daniel Dunbar /// getLoadXAction - Return how this load with extension should be treated: 2560f53cf22361d89690dcf58409decb43d2a3ad60fChris Lattner /// either it is legal, needs to be promoted to a larger size, needs to be 25796716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// expanded to some other code sequence, or the target has a custom expander 258835acabce13993e210b7cef0020a585125f9cb1eChris Lattner /// for it. 259835acabce13993e210b7cef0020a585125f9cb1eChris Lattner LegalizeAction getLoadXAction(unsigned LType, MVT::ValueType VT) const { 260835acabce13993e210b7cef0020a585125f9cb1eChris Lattner return (LegalizeAction)((LoadXActions[LType] >> (2*VT)) & 3); 261835acabce13993e210b7cef0020a585125f9cb1eChris Lattner } 262835acabce13993e210b7cef0020a585125f9cb1eChris Lattner 263835acabce13993e210b7cef0020a585125f9cb1eChris Lattner /// isLoadXLegal - Return true if the specified load with extension is legal 26496716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// on this target. 2650f53cf22361d89690dcf58409decb43d2a3ad60fChris Lattner bool isLoadXLegal(unsigned LType, MVT::ValueType VT) const { 266835acabce13993e210b7cef0020a585125f9cb1eChris Lattner return getLoadXAction(LType, VT) == Legal || 2671e35d0e9234836c4cea5ec9d1ec11dcc017911beChris Lattner getLoadXAction(LType, VT) == Custom; 2681e35d0e9234836c4cea5ec9d1ec11dcc017911beChris Lattner } 26996716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes 2701e35d0e9234836c4cea5ec9d1ec11dcc017911beChris Lattner /// getStoreXAction - Return how this store with truncation should be treated: 27196716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// either it is legal, needs to be promoted to a larger size, needs to be 272a8168ec732781813172f203f73956561a09f4a67Chris Lattner /// expanded to some other code sequence, or the target has a custom expander 27396716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// for it. 2741ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner LegalizeAction getStoreXAction(MVT::ValueType VT) const { 2751ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner return (LegalizeAction)((StoreXActions >> (2*VT)) & 3); 2765526b699014b0b58e08d7d43e28084589eda26f2Chris Lattner } 277a8168ec732781813172f203f73956561a09f4a67Chris Lattner 27896716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// isStoreXLegal - Return true if the specified store with truncation is 2795526b699014b0b58e08d7d43e28084589eda26f2Chris Lattner /// legal on this target. 2805526b699014b0b58e08d7d43e28084589eda26f2Chris Lattner bool isStoreXLegal(MVT::ValueType VT) const { 2815526b699014b0b58e08d7d43e28084589eda26f2Chris Lattner return getStoreXAction(VT) == Legal || getStoreXAction(VT) == Custom; 2825526b699014b0b58e08d7d43e28084589eda26f2Chris Lattner } 283a8168ec732781813172f203f73956561a09f4a67Chris Lattner 284a8168ec732781813172f203f73956561a09f4a67Chris Lattner /// getIndexedLoadAction - Return how the indexed load should be treated: 285a8168ec732781813172f203f73956561a09f4a67Chris Lattner /// either it is legal, needs to be promoted to a larger size, needs to be 286a8168ec732781813172f203f73956561a09f4a67Chris Lattner /// expanded to some other code sequence, or the target has a custom expander 2871e35d0e9234836c4cea5ec9d1ec11dcc017911beChris Lattner /// for it. 28837ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner LegalizeAction 289cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner getIndexedLoadAction(unsigned IdxMode, MVT::ValueType VT) const { 290a8168ec732781813172f203f73956561a09f4a67Chris Lattner return (LegalizeAction)((IndexedModeActions[0][IdxMode] >> (2*VT)) & 3); 291a8168ec732781813172f203f73956561a09f4a67Chris Lattner } 29296716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes 293a8168ec732781813172f203f73956561a09f4a67Chris Lattner /// isIndexedLoadLegal - Return true if the specified indexed load is legal 294a8168ec732781813172f203f73956561a09f4a67Chris Lattner /// on this target. 295a8168ec732781813172f203f73956561a09f4a67Chris Lattner bool isIndexedLoadLegal(unsigned IdxMode, MVT::ValueType VT) const { 296a8168ec732781813172f203f73956561a09f4a67Chris Lattner return getIndexedLoadAction(IdxMode, VT) == Legal || 2978496a26113859288730d0d97637d032de53b2a7eChris Lattner getIndexedLoadAction(IdxMode, VT) == Custom; 29837ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner } 299a8168ec732781813172f203f73956561a09f4a67Chris Lattner 3001ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner /// getIndexedStoreAction - Return how the indexed store should be treated: 30196716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// either it is legal, needs to be promoted to a larger size, needs to be 302a8168ec732781813172f203f73956561a09f4a67Chris Lattner /// expanded to some other code sequence, or the target has a custom expander 3038496a26113859288730d0d97637d032de53b2a7eChris Lattner /// for it. 30437ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner LegalizeAction 305cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner getIndexedStoreAction(unsigned IdxMode, MVT::ValueType VT) const { 306a8168ec732781813172f203f73956561a09f4a67Chris Lattner return (LegalizeAction)((IndexedModeActions[1][IdxMode] >> (2*VT)) & 3); 307a8168ec732781813172f203f73956561a09f4a67Chris Lattner } 30896716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes 309a8168ec732781813172f203f73956561a09f4a67Chris Lattner /// isIndexedStoreLegal - Return true if the specified indexed load is legal 31037ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// on this target. 311a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindola bool isIndexedStoreLegal(unsigned IdxMode, MVT::ValueType VT) const { 312a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindola return getIndexedStoreAction(IdxMode, VT) == Legal || 3130e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner getIndexedStoreAction(IdxMode, VT) == Custom; 3140e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner } 31596716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes 3160e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// getTypeToPromoteTo - If the action for this operation is to promote, this 3170e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// method returns the ValueType to promote to. 3180e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner MVT::ValueType getTypeToPromoteTo(unsigned Op, MVT::ValueType VT) const { 31996716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes assert(getOperationAction(Op, VT) == Promote && 3200e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner "This operation isn't promoted!"); 3210e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner 3220e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner // See if this has an explicit type specified. 3230e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner std::map<std::pair<unsigned, MVT::ValueType>, 3240e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner MVT::ValueType>::const_iterator PTTI = 32537ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner PromoteToType.find(std::make_pair(Op, VT)); 3260e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner if (PTTI != PromoteToType.end()) return PTTI->second; 3278496a26113859288730d0d97637d032de53b2a7eChris Lattner 3280e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner assert((MVT::isInteger(VT) || MVT::isFloatingPoint(VT)) && 32937ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner "Cannot autopromote this type, add it with AddPromotedToType."); 3300e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner 331618d0ed4bc0b68d87f86eace0cd6b9c05329dfc7Chris Lattner MVT::ValueType NVT = VT; 332618d0ed4bc0b68d87f86eace0cd6b9c05329dfc7Chris Lattner do { 333618d0ed4bc0b68d87f86eace0cd6b9c05329dfc7Chris Lattner NVT = (MVT::ValueType)(NVT+1); 334618d0ed4bc0b68d87f86eace0cd6b9c05329dfc7Chris Lattner assert(MVT::isInteger(NVT) == MVT::isInteger(VT) && NVT != MVT::isVoid && 3350e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner "Didn't find type to promote to!"); 33637ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner } while (!isTypeLegal(NVT) || 3378496a26113859288730d0d97637d032de53b2a7eChris Lattner getOperationAction(Op, NVT) == Promote); 3380e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner return NVT; 33937ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner } 3400e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner 3410e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// getValueType - Return the MVT::ValueType corresponding to this LLVM type. 3420e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// This is fixed by the LLVM operations except for the pointer size. 34337ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner MVT::ValueType getValueType(const Type *Ty) const; 3441ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner 34596716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// getNumElements - Return the number of registers that this ValueType will 3460e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// eventually require. This is one for any types promoted to live in larger 3470e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// registers, but may be more than one for types (like i64) that are split 3480e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// into pieces. 34996716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes unsigned getNumElements(MVT::ValueType VT) const { 3500e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner return NumElementsForVT[VT]; 35196716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes } 3520e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner 3530e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// hasTargetDAGCombine - If true, the target has custom DAG combine 3540e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// transformations that it can perform for the specified node. 3550e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner bool hasTargetDAGCombine(ISD::NodeType NT) const { 3560e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner return TargetDAGCombineArray[NT >> 3] & (1 << (NT&7)); 3570e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner } 35837ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner 3590e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// This function returns the maximum number of store operations permitted 3600e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// to replace a call to llvm.memset. The value is set by the target at the 3610e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// performance threshold for such a replacement. 3620e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// @brief Get maximum # of store operations permitted for llvm.memset 3630e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner unsigned getMaxStoresPerMemset() const { return maxStoresPerMemset; } 3640e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner 36537ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// This function returns the maximum number of store operations permitted 3660e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// to replace a call to llvm.memcpy. The value is set by the target at the 36796716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// performance threshold for such a replacement. 3680e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner /// @brief Get maximum # of store operations permitted for llvm.memcpy 3690e73c39c70a00bf729cd58bd36e1c55afe565c6dChris Lattner unsigned getMaxStoresPerMemcpy() const { return maxStoresPerMemcpy; } 370cf65339b52e09be5d329e45d3847a8e3a2ee08bdChris Lattner 3718496a26113859288730d0d97637d032de53b2a7eChris Lattner /// This function returns the maximum number of store operations permitted 372a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindola /// to replace a call to llvm.memmove. The value is set by the target at the 373a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindola /// performance threshold for such a replacement. 3741ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner /// @brief Get maximum # of store operations permitted for llvm.memmove 3751ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner unsigned getMaxStoresPerMemmove() const { return maxStoresPerMemmove; } 37699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 37799405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// This function returns true if the target allows unaligned memory accesses. 37899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// This is used, for example, in situations where an array copy/move/set is 3791cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes /// converted to a sequence of store operations. It's use helps to ensure that 3801cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes /// such replacements don't generate code that causes an alignment error 3811cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes /// (trap) on the target machine. 382788184365a4a949eb83b0036045e6793bc6c20f0Bruno Cardoso Lopes /// @brief Determine if the target supports unaligned memory accesses. 383e943c15621035fa7fbeda7b4922d06a8c2b05b2dBruno Cardoso Lopes bool allowsUnalignedMemoryAccesses() const { 384788184365a4a949eb83b0036045e6793bc6c20f0Bruno Cardoso Lopes return allowUnalignedMemoryAccesses; 385788184365a4a949eb83b0036045e6793bc6c20f0Bruno Cardoso Lopes } 38699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 38799405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// usesUnderscoreSetJmp - Determine if we should use _setjmp or setjmp 38899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// to implement llvm.setjmp. 38999405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes bool usesUnderscoreSetJmp() const { 39099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes return UseUnderscoreSetJmp; 39199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes } 39299405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 39399405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// usesUnderscoreLongJmp - Determine if we should use _longjmp or longjmp 394c902a59f4c786a2a047f0b4c964a93108f248915Bruno Cardoso Lopes /// to implement llvm.longjmp. 395c902a59f4c786a2a047f0b4c964a93108f248915Bruno Cardoso Lopes bool usesUnderscoreLongJmp() const { 396c902a59f4c786a2a047f0b4c964a93108f248915Bruno Cardoso Lopes return UseUnderscoreLongJmp; 397c902a59f4c786a2a047f0b4c964a93108f248915Bruno Cardoso Lopes } 398c902a59f4c786a2a047f0b4c964a93108f248915Bruno Cardoso Lopes 399c902a59f4c786a2a047f0b4c964a93108f248915Bruno Cardoso Lopes /// getStackPointerRegisterToSaveRestore - If a physical register, this 400c902a59f4c786a2a047f0b4c964a93108f248915Bruno Cardoso Lopes /// specifies the register that llvm.savestack/llvm.restorestack should save 40199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// and restore. 40299405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes unsigned getStackPointerRegisterToSaveRestore() const { 40399405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes return StackPointerRegisterToSaveRestore; 40499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes } 40599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 40699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// getJumpBufSize - returns the target's jmp_buf size in bytes (if never 40799405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// set, the default is 200) 40899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes unsigned getJumpBufSize() const { 40999405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes return JumpBufSize; 41099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes } 41199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 41299405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// getJumpBufAlignment - returns the target's jmp_buf alignment in bytes 41399405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// (if never set, the default is 0) 41499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes unsigned getJumpBufAlignment() const { 41599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes return JumpBufAlignment; 41699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes } 41799405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 41899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// getPreIndexedAddressParts - returns true by value, base pointer and 41999405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// offset pointer and addressing mode by reference if the node's address 42099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// can be legally represented as pre-indexed load / store address. 42199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes virtual bool getPreIndexedAddressParts(SDNode *N, SDOperand &Base, 42299405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes SDOperand &Offset, 42399405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes ISD::MemIndexedMode &AM, 42499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes SelectionDAG &DAG) { 42599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes return false; 42699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes } 42799405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 42899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// getPostIndexedAddressParts - returns true by value, base pointer and 42999405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// offset pointer and addressing mode by reference if this node can be 43099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// combined with a load / store to form a post-indexed load / store. 43199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes virtual bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, 43299405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes SDOperand &Base, SDOperand &Offset, 43399405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes ISD::MemIndexedMode &AM, 43499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes SelectionDAG &DAG) { 43599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes return false; 43699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes } 4377be0d2c8e944d0f51db8abb0fb4c8fb7c1bfe8f8Bruno Cardoso Lopes 43899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes //===--------------------------------------------------------------------===// 43999405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes // TargetLowering Optimization Methods 44099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes // 44199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 44299405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// TargetLoweringOpt - A convenience struct that encapsulates a DAG, and two 4437be0d2c8e944d0f51db8abb0fb4c8fb7c1bfe8f8Bruno Cardoso Lopes /// SDOperands for returning information from TargetLowering to its clients 4447be0d2c8e944d0f51db8abb0fb4c8fb7c1bfe8f8Bruno Cardoso Lopes /// that want to combine 4457be0d2c8e944d0f51db8abb0fb4c8fb7c1bfe8f8Bruno Cardoso Lopes struct TargetLoweringOpt { 4467be0d2c8e944d0f51db8abb0fb4c8fb7c1bfe8f8Bruno Cardoso Lopes SelectionDAG &DAG; 447e943c15621035fa7fbeda7b4922d06a8c2b05b2dBruno Cardoso Lopes SDOperand Old; 4486596a6207627ed59f568883924a21e642934c083Bruno Cardoso Lopes SDOperand New; 4496596a6207627ed59f568883924a21e642934c083Bruno Cardoso Lopes 450e943c15621035fa7fbeda7b4922d06a8c2b05b2dBruno Cardoso Lopes TargetLoweringOpt(SelectionDAG &InDAG) : DAG(InDAG) {} 45187a85c7ef0d1a96c73473de90d3b2b28d24538a5Bruno Cardoso Lopes 45287a85c7ef0d1a96c73473de90d3b2b28d24538a5Bruno Cardoso Lopes bool CombineTo(SDOperand O, SDOperand N) { 45399405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes Old = O; 45499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes New = N; 45599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes return true; 45699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes } 45799405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 45899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// ShrinkDemandedConstant - Check to see if the specified operand of the 45999405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// specified instruction is a constant integer. If so, check to see if there 46099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// are any bits set in the constant that are not demanded. If so, shrink the 46199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// constant and return true. 46299405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes bool ShrinkDemandedConstant(SDOperand Op, uint64_t Demanded); 46399405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes }; 46499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 46599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// MaskedValueIsZero - Return true if 'Op & Mask' is known to be zero. We 46699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// use this predicate to simplify operations downstream. Op and Mask are 46799405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// known to be the same type. 46899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes bool MaskedValueIsZero(SDOperand Op, uint64_t Mask, unsigned Depth = 0) 46999405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes const; 47099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 471161476ec343161c6c6ab16df775d853fcecd77c3Bruno Cardoso Lopes /// ComputeMaskedBits - Determine which of the bits specified in Mask are 472161476ec343161c6c6ab16df775d853fcecd77c3Bruno Cardoso Lopes /// known to be either zero or one and return them in the KnownZero/KnownOne 473161476ec343161c6c6ab16df775d853fcecd77c3Bruno Cardoso Lopes /// bitsets. This code only analyzes bits in Mask, in order to short-circuit 47499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// processing. Targets can implement the computeMaskedBitsForTargetNode 47599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// method, to allow target nodes to be understood. 476e86b01c153ba52307ecb6e7513ec33f57caedfddBruno Cardoso Lopes void ComputeMaskedBits(SDOperand Op, uint64_t Mask, uint64_t &KnownZero, 477e86b01c153ba52307ecb6e7513ec33f57caedfddBruno Cardoso Lopes uint64_t &KnownOne, unsigned Depth = 0) const; 478e86b01c153ba52307ecb6e7513ec33f57caedfddBruno Cardoso Lopes 479e86b01c153ba52307ecb6e7513ec33f57caedfddBruno Cardoso Lopes /// SimplifyDemandedBits - Look at Op. At this point, we know that only the 480e86b01c153ba52307ecb6e7513ec33f57caedfddBruno Cardoso Lopes /// DemandedMask bits of the result of Op are ever used downstream. If we can 481e86b01c153ba52307ecb6e7513ec33f57caedfddBruno Cardoso Lopes /// use this information to simplify Op, create a new simplified DAG node and 482e86b01c153ba52307ecb6e7513ec33f57caedfddBruno Cardoso Lopes /// return true, returning the original and new nodes in Old and New. 483e86b01c153ba52307ecb6e7513ec33f57caedfddBruno Cardoso Lopes /// Otherwise, analyze the expression and return a mask of KnownOne and 484e86b01c153ba52307ecb6e7513ec33f57caedfddBruno Cardoso Lopes /// KnownZero bits for the expression (used to simplify the caller). 48599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// The KnownZero/One bits may only be accurate for those bits in the 486161476ec343161c6c6ab16df775d853fcecd77c3Bruno Cardoso Lopes /// DemandedMask. 4874b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes bool SimplifyDemandedBits(SDOperand Op, uint64_t DemandedMask, 488161476ec343161c6c6ab16df775d853fcecd77c3Bruno Cardoso Lopes uint64_t &KnownZero, uint64_t &KnownOne, 48999405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes TargetLoweringOpt &TLO, unsigned Depth = 0) const; 49099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 4914b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes /// computeMaskedBitsForTargetNode - Determine which of the bits specified in 4924b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes /// Mask are known to be either zero or one and return them in the 4934b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes /// KnownZero/KnownOne bitsets. 4944b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes virtual void computeMaskedBitsForTargetNode(const SDOperand Op, 4954b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes uint64_t Mask, 496147b7cad2fefa3260e2da8f7cfe31ac07f352cebBruno Cardoso Lopes uint64_t &KnownZero, 497147b7cad2fefa3260e2da8f7cfe31ac07f352cebBruno Cardoso Lopes uint64_t &KnownOne, 498147b7cad2fefa3260e2da8f7cfe31ac07f352cebBruno Cardoso Lopes unsigned Depth = 0) const; 499147b7cad2fefa3260e2da8f7cfe31ac07f352cebBruno Cardoso Lopes 500147b7cad2fefa3260e2da8f7cfe31ac07f352cebBruno Cardoso Lopes /// ComputeNumSignBits - Return the number of times the sign bit of the 50199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// register is replicated into the other bits. We know that at least 1 bit 502147b7cad2fefa3260e2da8f7cfe31ac07f352cebBruno Cardoso Lopes /// is always equal to the sign bit (itself), but other cases can give us 503788184365a4a949eb83b0036045e6793bc6c20f0Bruno Cardoso Lopes /// information. For example, immediately after an "SRA X, 2", we know that 50499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// the top 3 bits are all equal to each other, so we return 3. 5054b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes unsigned ComputeNumSignBits(SDOperand Op, unsigned Depth = 0) const; 50699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 507788184365a4a949eb83b0036045e6793bc6c20f0Bruno Cardoso Lopes /// ComputeNumSignBitsForTargetNode - This method can be implemented by 5084b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes /// targets that want to expose additional information about sign bits to the 509788184365a4a949eb83b0036045e6793bc6c20f0Bruno Cardoso Lopes /// DAG Combiner. 510788184365a4a949eb83b0036045e6793bc6c20f0Bruno Cardoso Lopes virtual unsigned ComputeNumSignBitsForTargetNode(SDOperand Op, 511788184365a4a949eb83b0036045e6793bc6c20f0Bruno Cardoso Lopes unsigned Depth = 0) const; 5124b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes 5134b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes struct DAGCombinerInfo { 5144b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes void *DC; // The DAG Combiner object. 5154b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes bool BeforeLegalize; 5164b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes public: 51707de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes SelectionDAG &DAG; 5180106680a2c857b2fafeab3d5559748f1e98780b9Bruno Cardoso Lopes 519e943c15621035fa7fbeda7b4922d06a8c2b05b2dBruno Cardoso Lopes DAGCombinerInfo(SelectionDAG &dag, bool bl, void *dc) 52007de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes : DC(dc), BeforeLegalize(bl), DAG(dag) {} 52107de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes 522161476ec343161c6c6ab16df775d853fcecd77c3Bruno Cardoso Lopes bool isBeforeLegalize() const { return BeforeLegalize; } 523161476ec343161c6c6ab16df775d853fcecd77c3Bruno Cardoso Lopes 52499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes void AddToWorklist(SDNode *N); 52599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes SDOperand CombineTo(SDNode *N, const std::vector<SDOperand> &To); 526161476ec343161c6c6ab16df775d853fcecd77c3Bruno Cardoso Lopes SDOperand CombineTo(SDNode *N, SDOperand Res); 527161476ec343161c6c6ab16df775d853fcecd77c3Bruno Cardoso Lopes SDOperand CombineTo(SDNode *N, SDOperand Res0, SDOperand Res1); 528c902a59f4c786a2a047f0b4c964a93108f248915Bruno Cardoso Lopes }; 529c902a59f4c786a2a047f0b4c964a93108f248915Bruno Cardoso Lopes 53099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// PerformDAGCombine - This method will be invoked for all target nodes and 53199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// for any target-independent nodes that the target has registered with 532cf6ca031288332c4fb43a314a3c30df8deeb2ffbBruno Cardoso Lopes /// invoke it for. 533cf6ca031288332c4fb43a314a3c30df8deeb2ffbBruno Cardoso Lopes /// 534cf6ca031288332c4fb43a314a3c30df8deeb2ffbBruno Cardoso Lopes /// The semantics are as follows: 535cf6ca031288332c4fb43a314a3c30df8deeb2ffbBruno Cardoso Lopes /// Return Value: 5366596a6207627ed59f568883924a21e642934c083Bruno Cardoso Lopes /// SDOperand.Val == 0 - No change was made 5376596a6207627ed59f568883924a21e642934c083Bruno Cardoso Lopes /// SDOperand.Val == N - N was replaced, is dead, and is already handled. 5386596a6207627ed59f568883924a21e642934c083Bruno Cardoso Lopes /// otherwise - N should be replaced by the returned Operand. 5396596a6207627ed59f568883924a21e642934c083Bruno Cardoso Lopes /// 5405a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes /// In addition, methods provided by DAGCombinerInfo may be used to perform 5415a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes /// more complex transformations. 5425a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes /// 5435a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes virtual SDOperand PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const; 5445a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes 5455a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes //===--------------------------------------------------------------------===// 5466596a6207627ed59f568883924a21e642934c083Bruno Cardoso Lopes // TargetLowering Configuration Methods - These methods should be invoked by 5476596a6207627ed59f568883924a21e642934c083Bruno Cardoso Lopes // the derived class constructor to configure this object for the target. 5486596a6207627ed59f568883924a21e642934c083Bruno Cardoso Lopes // 5495a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes 5505a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopesprotected: 55199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// setUsesGlobalOffsetTable - Specify that this target does or doesn't use a 55299405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// GOT for PC-relative code. 5531cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes void setUsesGlobalOffsetTable(bool V) { UsesGlobalOffsetTable = V; } 5541cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes 5551cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes /// setShiftAmountType - Describe the type that should be used for shift 55699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// amounts. This type defaults to the pointer type. 55799405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes void setShiftAmountType(MVT::ValueType VT) { ShiftAmountTy = VT; } 55899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 55999405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// setSetCCResultType - Describe the type that shoudl be used as the result 56099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// of a setcc operation. This defaults to the pointer type. 56199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes void setSetCCResultType(MVT::ValueType VT) { SetCCResultTy = VT; } 56299405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 56399405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// setSetCCResultContents - Specify how the target extends the result of a 56499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// setcc operation in a register. 56599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes void setSetCCResultContents(SetCCResultValue Ty) { SetCCResultContents = Ty; } 56699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 56799405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// setSchedulingPreference - Specify the target scheduling preference. 56899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes void setSchedulingPreference(SchedPreference Pref) { 569f5cd8c51e3d09a2af32e03414e75d3b50f47d0aaBruno Cardoso Lopes SchedPreferenceInfo = Pref; 57099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes } 57199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 57299405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// setShiftAmountFlavor - Describe how the target handles out of range shift 57399405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// amounts. 57499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes void setShiftAmountFlavor(OutOfRangeShiftAmount OORSA) { 57599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes ShiftAmtHandling = OORSA; 57699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes } 5776596a6207627ed59f568883924a21e642934c083Bruno Cardoso Lopes 57899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// setUseUnderscoreSetJmp - Indicate whether this target prefers to 57999405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// use _setjmp to implement llvm.setjmp or the non _ version. 58099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// Defaults to false. 58139a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner void setUseUnderscoreSetJmp(bool Val) { 58239a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner UseUnderscoreSetJmp = Val; 58339a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner } 58499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 58539a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// setUseUnderscoreLongJmp - Indicate whether this target prefers to 5867e85180d15c4d5a451fbc078f7194a41c6230a57Chris Lattner /// use _longjmp to implement llvm.longjmp or the non _ version. 58739a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// Defaults to false. 588e4f6907a7a38f73a18e5f193fbe5f5d86867b3b4Bruno Cardoso Lopes void setUseUnderscoreLongJmp(bool Val) { 58996716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes UseUnderscoreLongJmp = Val; 59039a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner } 59196716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes 59239a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// setStackPointerRegisterToSaveRestore - If set to a physical register, this 59339a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// specifies the register that llvm.savestack/llvm.restorestack should save 59439a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// and restore. 59539a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner void setStackPointerRegisterToSaveRestore(unsigned R) { 59696716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes StackPointerRegisterToSaveRestore = R; 59739a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner } 59839a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner 59939a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// SelectIsExpensive - Tells the code generator not to expand operations 60039a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// into sequences that use the select operations if possible. 60139a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner void setSelectIsExpensive() { SelectIsExpensive = true; } 60239a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner 60339a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// setIntDivIsCheap - Tells the code generator that integer divide is 604faa75f6f6f2b37359a458fd9acd57c58ee26eea9Chris Lattner /// expensive, and if possible, should be replaced by an alternate sequence 605faa75f6f6f2b37359a458fd9acd57c58ee26eea9Chris Lattner /// of instructions not containing an integer divide. 606e4f6907a7a38f73a18e5f193fbe5f5d86867b3b4Bruno Cardoso Lopes void setIntDivIsCheap(bool isCheap = true) { IntDivIsCheap = isCheap; } 60739a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner 60839a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// setPow2DivIsCheap - Tells the code generator that it shouldn't generate 60996716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// srl/add/sra for a signed divide by power of two, and let the target handle 61039a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// it. 61139a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner void setPow2DivIsCheap(bool isCheap = true) { Pow2DivIsCheap = isCheap; } 61239a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner 61339a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// addRegisterClass - Add the specified register class as an available 61439a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// regclass for the specified value type. This indicates the selector can 615e4f6907a7a38f73a18e5f193fbe5f5d86867b3b4Bruno Cardoso Lopes /// handle values of that class natively. 61639a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner void addRegisterClass(MVT::ValueType VT, TargetRegisterClass *RC) { 61739a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner AvailableRegClasses.push_back(std::make_pair(VT, RC)); 61839a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner RegClassForVT[VT] = RC; 61939a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner } 620e4f6907a7a38f73a18e5f193fbe5f5d86867b3b4Bruno Cardoso Lopes 62139a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// computeRegisterProperties - Once all of the register classes are added, 62239a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// this allows us to compute derived properties we expose. 62339a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner void computeRegisterProperties(); 62439a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner 62539a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// setOperationAction - Indicate that the specified operation does not work 626e4f6907a7a38f73a18e5f193fbe5f5d86867b3b4Bruno Cardoso Lopes /// with the specified type and indicate what to do about it. 62739a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner void setOperationAction(unsigned Op, MVT::ValueType VT, 62839a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner LegalizeAction Action) { 62939a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner assert(VT < 32 && Op < sizeof(OpActions)/sizeof(OpActions[0]) && 63039a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner "Table isn't big enough!"); 63139a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner OpActions[Op] &= ~(uint64_t(3UL) << VT*2); 63239a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner OpActions[Op] |= (uint64_t)Action << VT*2; 633e4f6907a7a38f73a18e5f193fbe5f5d86867b3b4Bruno Cardoso Lopes } 63439a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner 63539a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// setLoadXAction - Indicate that the specified load with extension does not 63639a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// work with the with specified type and indicate what to do about it. 63739a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner void setLoadXAction(unsigned ExtType, MVT::ValueType VT, 63839a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner LegalizeAction Action) { 63939a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner assert(VT < 32 && ExtType < sizeof(LoadXActions)/sizeof(LoadXActions[0]) && 64039a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner "Table isn't big enough!"); 64139a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner LoadXActions[ExtType] &= ~(uint64_t(3UL) << VT*2); 64239a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner LoadXActions[ExtType] |= (uint64_t)Action << VT*2; 64339a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner } 644ac0ed5dc082dff9ce359af5422f5b82047b4fe6bChris Lattner 64539a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// setStoreXAction - Indicate that the specified store with truncation does 64639a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// not work with the with specified type and indicate what to do about it. 64739a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner void setStoreXAction(MVT::ValueType VT, LegalizeAction Action) { 648e4f6907a7a38f73a18e5f193fbe5f5d86867b3b4Bruno Cardoso Lopes assert(VT < 32 && "Table isn't big enough!"); 64939a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner StoreXActions &= ~(uint64_t(3UL) << VT*2); 65039a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner StoreXActions |= (uint64_t)Action << VT*2; 65139a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner } 65239a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner 65339a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// setIndexedLoadAction - Indicate that the specified indexed load does or 654e4f6907a7a38f73a18e5f193fbe5f5d86867b3b4Bruno Cardoso Lopes /// does not work with the with specified type and indicate what to do abort 65539a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// it. NOTE: All indexed mode loads are initialized to Expand in 65639a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// TargetLowering.cpp 65739a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner void setIndexedLoadAction(unsigned IdxMode, MVT::ValueType VT, 65839a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner LegalizeAction Action) { 65939a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner assert(VT < 32 && IdxMode < 66039a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner sizeof(IndexedModeActions[0]) / sizeof(IndexedModeActions[0][0]) && 66139a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner "Table isn't big enough!"); 66239a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner IndexedModeActions[0][IdxMode] &= ~(uint64_t(3UL) << VT*2); 663e4f6907a7a38f73a18e5f193fbe5f5d86867b3b4Bruno Cardoso Lopes IndexedModeActions[0][IdxMode] |= (uint64_t)Action << VT*2; 66439a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner } 66539a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner 66639a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// setIndexedStoreAction - Indicate that the specified indexed store does or 66739a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// does not work with the with specified type and indicate what to do about 668e4f6907a7a38f73a18e5f193fbe5f5d86867b3b4Bruno Cardoso Lopes /// it. NOTE: All indexed mode stores are initialized to Expand in 66939a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// TargetLowering.cpp 67039a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner void setIndexedStoreAction(unsigned IdxMode, MVT::ValueType VT, 67139a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner LegalizeAction Action) { 67239a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner assert(VT < 32 && IdxMode < 67339a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner sizeof(IndexedModeActions[1]) / sizeof(IndexedModeActions[1][0]) && 67492b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner "Table isn't big enough!"); 6751cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes IndexedModeActions[1][IdxMode] &= ~(uint64_t(3UL) << VT*2); 6761cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes IndexedModeActions[1][IdxMode] |= (uint64_t)Action << VT*2; 6771cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes } 6781cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes 6799d19989fe36e4b1b0b6449f8e54e180220b8a90aChris Lattner /// AddPromotedToType - If Opc/OrigVT is specified as being promoted, the 6801e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// promotion code defaults to trying a larger integer/fp until it can find 68192b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner /// one that works. If that default is insufficient, this method can be used 682834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner /// by the target to override the default. 683834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner void AddPromotedToType(unsigned Opc, MVT::ValueType OrigVT, 684599b531a960833719f607d66c97871f1f5ad12c0Chris Lattner MVT::ValueType DestVT) { 685ac0ed5dc082dff9ce359af5422f5b82047b4fe6bChris Lattner PromoteToType[std::make_pair(Opc, OrigVT)] = DestVT; 686834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner } 687834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner 688834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner /// addLegalFPImmediate - Indicate that this target can instruction select 689834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner /// the specified FP immediate natively. 690834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner void addLegalFPImmediate(double Imm) { 691834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner LegalFPImmediates.push_back(Imm); 692834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner } 693834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner 694834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner /// setTargetDAGCombine - Targets should invoke this method for each target 695834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner /// independent node that they want to provide a custom DAG combiner for by 696834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner /// implementing the PerformDAGCombine virtual method. 69792b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner void setTargetDAGCombine(ISD::NodeType NT) { 69837ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner TargetDAGCombineArray[NT >> 3] |= 1 << (NT&7); 69992b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner } 70092b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner 70137ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// setJumpBufSize - Set the target's required jmp_buf buffer size (in 70292b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner /// bytes); default is 200 70392b1dfe5d8ce32b4389fccf94aa620682b2f5726Chris Lattner void setJumpBufSize(unsigned Size) { 7041cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes JumpBufSize = Size; 7051cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes } 7061cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes 7071cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes /// setJumpBufAlignment - Set the target's required jmp_buf buffer 7081cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes /// alignment (in bytes); default is 0 7091cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes void setJumpBufAlignment(unsigned Align) { 7101cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes JumpBufAlignment = Align; 7111cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes } 7121cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes 7131cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopespublic: 7141cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes 7151cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes //===--------------------------------------------------------------------===// 7161cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes // Lowering methods - These methods must be implemented by targets so that 7171cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes // the SelectionDAGLowering code knows how to lower these. 7181cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes // 7191cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes 7201cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes /// LowerArguments - This hook must be implemented to indicate how we should 72196716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// lower the arguments for the specified function, into the specified DAG. 7221e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner virtual std::vector<SDOperand> 7231e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner LowerArguments(Function &F, SelectionDAG &DAG); 72437ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner 72596716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// LowerCallTo - This hook lowers an abstract call to a function into an 7261e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// actual call. This returns a pair of operands. The first element is the 7278a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner /// return value for the function (if RetTy is not VoidTy). The second 7288a5072903e2037da1cfdaffa5a26be00f3d76a22Chris Lattner /// element is the outgoing token chain. 72937ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner struct ArgListEntry { 73078a194693bb9bbfa1080454cded0166265b803e5Chris Lattner SDOperand Node; 73178a194693bb9bbfa1080454cded0166265b803e5Chris Lattner const Type* Ty; 73278a194693bb9bbfa1080454cded0166265b803e5Chris Lattner bool isSigned; 73378a194693bb9bbfa1080454cded0166265b803e5Chris Lattner bool isInReg; 73496716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes bool isSRet; 7351e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner }; 7361e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner typedef std::vector<ArgListEntry> ArgListTy; 7371e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner virtual std::pair<SDOperand, SDOperand> 7381e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner LowerCallTo(SDOperand Chain, const Type *RetTy, bool RetTyIsSigned, 7391e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner bool isVarArg, unsigned CallingConv, bool isTailCall, 7401e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG); 7411e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner 7421e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// LowerOperation - This callback is invoked for operations that are 7431e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// unsupported by the target, which are registered to use 'custom' lowering, 7441e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// and whose defined values are all legal. 7451e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// If the target has no operations that require custom lowering, it need not 74637ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// implement this. The default implementation of this aborts. 7471e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG); 7481e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner 7491e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// CustomPromoteOperation - This callback is invoked for operations that are 75037ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// unsupported by the target, are registered to use 'custom' lowering, and 7511e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// whose type needs to be promoted. 7521e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner virtual SDOperand CustomPromoteOperation(SDOperand Op, SelectionDAG &DAG); 7531e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner 75437ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// getTargetNodeName() - This method returns the name of a target specific 7551e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// DAG node. 7561e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner virtual const char *getTargetNodeName(unsigned Opcode) const; 75737ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner 75837ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner //===--------------------------------------------------------------------===// 75937ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner // Inline Asm Support hooks 76037ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner // 76137ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner 76237ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner enum ConstraintType { 76337ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner C_Register, // Constraint represents a single register. 76437ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner C_RegisterClass, // Constraint represents one or more registers. 7651e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner C_Memory, // Memory constraint. 76696716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes C_Other, // Something else. 7671e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner C_Unknown // Unsupported constraint. 76839a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner }; 7691e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner 77039a612e6f9e63806af410a0ab0d81895391e4c79Chris Lattner /// getConstraintType - Given a constraint letter, return the type of 77137ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// constraint it is for this target. 7721e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner virtual ConstraintType getConstraintType(char ConstraintLetter) const; 77396716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes 7741e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner 7751e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// getRegClassForInlineAsmConstraint - Given a constraint letter (e.g. "r"), 77637ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// return a list of registers that can be used to satisfy the constraint. 77796716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// This should only be used for C_RegisterClass constraints. 7781e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner virtual std::vector<unsigned> 7791e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner getRegClassForInlineAsmConstraint(const std::string &Constraint, 7801e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner MVT::ValueType VT) const; 7811e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner 78237ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// getRegForInlineAsmConstraint - Given a physical register constraint (e.g. 7831e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// {edx}), return the register number and the register class for the 7841e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// register. 78537ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// 7861e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// Given a register class constraint, like 'r', if this corresponds directly 7871e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner /// to an LLVM register class, return a register of 0 and the register class 78899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// pointer. 78999405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// 79099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// This should only be used for C_Register constraints. On error, 79199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// this returns a register number of 0 and a null register class pointer.. 79299405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes virtual std::pair<unsigned, const TargetRegisterClass*> 79399405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes getRegForInlineAsmConstraint(const std::string &Constraint, 79499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes MVT::ValueType VT) const; 79599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 79699405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 797757e8d6d2e18495a247d0ae90293889ab8093babChris Lattner /// isOperandValidForConstraint - Return the specified operand (possibly 798757e8d6d2e18495a247d0ae90293889ab8093babChris Lattner /// modified) if the specified SDOperand is valid for the specified target 799757e8d6d2e18495a247d0ae90293889ab8093babChris Lattner /// constraint letter, otherwise return null. 80096716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes virtual SDOperand 801834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner isOperandValidForConstraint(SDOperand Op, char ConstraintLetter, 802834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner SelectionDAG &DAG); 803834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner 804834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner //===--------------------------------------------------------------------===// 805834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner // Scheduler hooks 806834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner // 807834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner 808834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner // InsertAtEndOfBasicBlock - This method should be implemented by targets that 809834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner // mark instructions with the 'usesCustomDAGSchedInserter' flag. These 81096716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes // instructions are special in various ways, which require special support to 81199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes // insert. The specified MachineInstr is created but not inserted into any 81299405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes // basic blocks, and the scheduler passes ownership of it to this method. 81396716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes virtual MachineBasicBlock *InsertAtEndOfBasicBlock(MachineInstr *MI, 814c3d57b179c33ef010ebbff003ce8c5d908cf9c01Bruno Cardoso Lopes MachineBasicBlock *MBB); 815c3d57b179c33ef010ebbff003ce8c5d908cf9c01Bruno Cardoso Lopes 816c3d57b179c33ef010ebbff003ce8c5d908cf9c01Bruno Cardoso Lopes //===--------------------------------------------------------------------===// 817c3d57b179c33ef010ebbff003ce8c5d908cf9c01Bruno Cardoso Lopes // Loop Strength Reduction hooks 818c3d57b179c33ef010ebbff003ce8c5d908cf9c01Bruno Cardoso Lopes // 819c3d57b179c33ef010ebbff003ce8c5d908cf9c01Bruno Cardoso Lopes 820e943c15621035fa7fbeda7b4922d06a8c2b05b2dBruno Cardoso Lopes /// isLegalAddressImmediate - Return true if the integer value or GlobalValue 821c3d57b179c33ef010ebbff003ce8c5d908cf9c01Bruno Cardoso Lopes /// can be used as the offset of the target addressing mode. 822e943c15621035fa7fbeda7b4922d06a8c2b05b2dBruno Cardoso Lopes virtual bool isLegalAddressImmediate(int64_t V) const; 823c3d57b179c33ef010ebbff003ce8c5d908cf9c01Bruno Cardoso Lopes virtual bool isLegalAddressImmediate(GlobalValue *GV) const; 82496716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes 825548abfcbd671b1144bf517b17643259dcae76f4fChris Lattner typedef std::vector<unsigned>::const_iterator legal_am_scale_iterator; 826834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner legal_am_scale_iterator legal_am_scale_begin() const { 827834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner return LegalAddressScales.begin(); 828834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner } 82996716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes legal_am_scale_iterator legal_am_scale_end() const { 830c3d57b179c33ef010ebbff003ce8c5d908cf9c01Bruno Cardoso Lopes return LegalAddressScales.end(); 831834df19452a551195ab012a8923b646b9a57a0d9Chris Lattner } 83299405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 8331cd050931fb429e4e2eab0fa4fe5b29e2cf4b9a4Bruno Cardoso Lopes //===--------------------------------------------------------------------===// 83496716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes // Div utility functions 835548abfcbd671b1144bf517b17643259dcae76f4fChris Lattner // 83674a2151392a08e202f497ece7a3129663526d431Chris Lattner SDOperand BuildSDIV(SDNode *N, SelectionDAG &DAG, 837548abfcbd671b1144bf517b17643259dcae76f4fChris Lattner std::vector<SDNode*>* Created) const; 838548abfcbd671b1144bf517b17643259dcae76f4fChris Lattner SDOperand BuildUDIV(SDNode *N, SelectionDAG &DAG, 839548abfcbd671b1144bf517b17643259dcae76f4fChris Lattner std::vector<SDNode*>* Created) const; 840548abfcbd671b1144bf517b17643259dcae76f4fChris Lattner 84199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 8421e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner //===--------------------------------------------------------------------===// 843be1778fea76e1f63b08f1f838fca88a0c8d9a883Chris Lattner // Runtime Library hooks 844be1778fea76e1f63b08f1f838fca88a0c8d9a883Chris Lattner // 8451ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner 8468b0f7a7d8627392c8faae3801cc91689406960cfChris Lattner /// setLibcallName - Rename the default libcall routine name for the specified 847757e8d6d2e18495a247d0ae90293889ab8093babChris Lattner /// libcall. 848757e8d6d2e18495a247d0ae90293889ab8093babChris Lattner void setLibcallName(RTLIB::Libcall Call, const char *Name) { 8498b0f7a7d8627392c8faae3801cc91689406960cfChris Lattner LibcallRoutineNames[Call] = Name; 85037ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner } 85128249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner 85259f8a6a66621f7c6f45b838e48fbf210af9d1fb5Chris Lattner /// getLibcallName - Get the libcall routine name for the specified libcall. 85340cc3f8783a4e426a0d439bb2b070b5c072b5947Chris Lattner /// 85440cc3f8783a4e426a0d439bb2b070b5c072b5947Chris Lattner const char *getLibcallName(RTLIB::Libcall Call) const { 85540cc3f8783a4e426a0d439bb2b070b5c072b5947Chris Lattner return LibcallRoutineNames[Call]; 85640cc3f8783a4e426a0d439bb2b070b5c072b5947Chris Lattner } 85740cc3f8783a4e426a0d439bb2b070b5c072b5947Chris Lattner 85840cc3f8783a4e426a0d439bb2b070b5c072b5947Chris Lattnerprotected: 85940cc3f8783a4e426a0d439bb2b070b5c072b5947Chris Lattner /// addLegalAddressScale - Add a integer (> 1) value which can be used as 86059f8a6a66621f7c6f45b838e48fbf210af9d1fb5Chris Lattner /// scale in the target addressing mode. Note: the ordering matters so the 86159f8a6a66621f7c6f45b838e48fbf210af9d1fb5Chris Lattner /// least efficient ones should be entered first. 86259f8a6a66621f7c6f45b838e48fbf210af9d1fb5Chris Lattner void addLegalAddressScale(unsigned Scale) { 86359f8a6a66621f7c6f45b838e48fbf210af9d1fb5Chris Lattner LegalAddressScales.push_back(Scale); 86459f8a6a66621f7c6f45b838e48fbf210af9d1fb5Chris Lattner } 86559f8a6a66621f7c6f45b838e48fbf210af9d1fb5Chris Lattner 86659f8a6a66621f7c6f45b838e48fbf210af9d1fb5Chris Lattnerprivate: 86796716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes std::vector<unsigned> LegalAddressScales; 8688b0f7a7d8627392c8faae3801cc91689406960cfChris Lattner 86937ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner TargetMachine &TM; 8701e80f403e225a72016581e34b05dca9b5ebd9445Chris Lattner const TargetData *TD; 87196716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes 87228249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// IsLittleEndian - True if this is a little endian target. 87337ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// 87428249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner bool IsLittleEndian; 87537ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner 87628249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// PointerTy - The type to use for pointers, usually i32 or i64. 87728249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// 87896716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes MVT::ValueType PointerTy; 8791ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner 88037ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner /// UsesGlobalOffsetTable - True if this target uses a GOT for PIC codegen. 8814b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes /// 8824b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes bool UsesGlobalOffsetTable; 8834b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes 8844b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes /// ShiftAmountTy - The type to use for shift amounts, usually i8 or whatever 8854b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes /// PointerTy is. 8861ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner MVT::ValueType ShiftAmountTy; 8874b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes 888835acabce13993e210b7cef0020a585125f9cb1eChris Lattner OutOfRangeShiftAmount ShiftAmtHandling; 8894b13f3cf3d44219371ca8cdfe699ebdc5e12f7f8Bruno Cardoso Lopes 8901ac23b10384543fcc7343beeac542b2ab626eeecChris Lattner /// SelectIsExpensive - Tells the code generator not to expand operations 89196716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// into sequences that use the select operations if possible. 892daa45557931bb72e6b9f6b4725ac2cb1bd5168e9Chris Lattner bool SelectIsExpensive; 89337ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner 89499405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// IntDivIsCheap - Tells the code generator not to expand integer divides by 89599405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// constants into a sequence of muls, adds, and shifts. This is a hack until 896c3d57b179c33ef010ebbff003ce8c5d908cf9c01Bruno Cardoso Lopes /// a real cost model is in place. If we ever optimize for size, this will be 89799405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// set to true unconditionally. 89899405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes bool IntDivIsCheap; 89999405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes 90099405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// Pow2DivIsCheap - Tells the code generator that it shouldn't generate 90199405df044f2c584242e711cc9023ec90356da82Bruno Cardoso Lopes /// srl/add/sra for a signed divide by power of two, and let the target handle 902daa45557931bb72e6b9f6b4725ac2cb1bd5168e9Chris Lattner /// it. 90396716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes bool Pow2DivIsCheap; 904daa45557931bb72e6b9f6b4725ac2cb1bd5168e9Chris Lattner 905ac0ed5dc082dff9ce359af5422f5b82047b4fe6bChris Lattner /// SetCCResultTy - The type that SetCC operations use. This defaults to the 9061cf44fc051e05c7cd96a4b071b654381338baae9Chris Lattner /// PointerTy. 907c3d57b179c33ef010ebbff003ce8c5d908cf9c01Bruno Cardoso Lopes MVT::ValueType SetCCResultTy; 9081cf44fc051e05c7cd96a4b071b654381338baae9Chris Lattner 9091cf44fc051e05c7cd96a4b071b654381338baae9Chris Lattner /// SetCCResultContents - Information about the contents of the high-bits in 9101cf44fc051e05c7cd96a4b071b654381338baae9Chris Lattner /// the result of a setcc comparison operation. 911daa45557931bb72e6b9f6b4725ac2cb1bd5168e9Chris Lattner SetCCResultValue SetCCResultContents; 9121cf44fc051e05c7cd96a4b071b654381338baae9Chris Lattner 91396716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes /// SchedPreferenceInfo - The target scheduling preference: shortest possible 9141cf44fc051e05c7cd96a4b071b654381338baae9Chris Lattner /// total cycles or lowest register usage. 915835acabce13993e210b7cef0020a585125f9cb1eChris Lattner SchedPreference SchedPreferenceInfo; 916daa45557931bb72e6b9f6b4725ac2cb1bd5168e9Chris Lattner 917daa45557931bb72e6b9f6b4725ac2cb1bd5168e9Chris Lattner /// UseUnderscoreSetJmp - This target prefers to use _setjmp to implement 918daa45557931bb72e6b9f6b4725ac2cb1bd5168e9Chris Lattner /// llvm.setjmp. Defaults to false. 91982ed17eb472102cb6711b832183ee4816ad9a656Chris Lattner bool UseUnderscoreSetJmp; 92082ed17eb472102cb6711b832183ee4816ad9a656Chris Lattner 92182ed17eb472102cb6711b832183ee4816ad9a656Chris Lattner /// UseUnderscoreLongJmp - This target prefers to use _longjmp to implement 92282ed17eb472102cb6711b832183ee4816ad9a656Chris Lattner /// llvm.longjmp. Defaults to false. 9238b0f7a7d8627392c8faae3801cc91689406960cfChris Lattner bool UseUnderscoreLongJmp; 9245a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes 9255a3a4767502341f304a8015580ab05ed74161ab0Bruno Cardoso Lopes /// JumpBufSize - The size, in bytes, of the target's jmp_buf buffers 92637ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner unsigned JumpBufSize; 927eaca5fa8e6a2cb0f84a635da5f1f0f670776d0a5Chris Lattner 928eaca5fa8e6a2cb0f84a635da5f1f0f670776d0a5Chris Lattner /// JumpBufAlignment - The alignment, in bytes, of the target's jmp_buf 929eaca5fa8e6a2cb0f84a635da5f1f0f670776d0a5Chris Lattner /// buffers 93082ed17eb472102cb6711b832183ee4816ad9a656Chris Lattner unsigned JumpBufAlignment; 93182ed17eb472102cb6711b832183ee4816ad9a656Chris Lattner 93282ed17eb472102cb6711b832183ee4816ad9a656Chris Lattner /// StackPointerRegisterToSaveRestore - If set to a physical register, this 93382ed17eb472102cb6711b832183ee4816ad9a656Chris Lattner /// specifies the register that llvm.savestack/llvm.restorestack should save 9348b0f7a7d8627392c8faae3801cc91689406960cfChris Lattner /// and restore. 93537ce80eca3159b3a7654cc34ea9c1202f38335caChris Lattner unsigned StackPointerRegisterToSaveRestore; 93682ed17eb472102cb6711b832183ee4816ad9a656Chris Lattner 937835acabce13993e210b7cef0020a585125f9cb1eChris Lattner /// RegClassForVT - This indicates the default register class to use for 938ac0ed5dc082dff9ce359af5422f5b82047b4fe6bChris Lattner /// each ValueType the target supports natively. 93982ed17eb472102cb6711b832183ee4816ad9a656Chris Lattner TargetRegisterClass *RegClassForVT[MVT::LAST_VALUETYPE]; 9400d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner unsigned char NumElementsForVT[MVT::LAST_VALUETYPE]; 9410d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner 9420d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner /// TransformToType - For any value types we are promoting or expanding, this 9430d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner /// contains the value type that we are changing to. For Expanded types, this 944a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner /// contains one step of the expand (e.g. i64 -> i32), even if there are 945a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner /// multiple steps required (e.g. i64 -> i16). For types natively supported 946a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner /// by the system, this holds the same type (e.g. i32 -> i32). 947a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner MVT::ValueType TransformToType[MVT::LAST_VALUETYPE]; 948a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner 949a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner /// OpActions - For each operation and each value type, keep a LegalizeAction 950a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner /// that indicates how instruction selection should deal with the operation. 951a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner /// Most operations are Legal (aka, supported natively by the target), but 952a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner /// operations that are not should be described. Note that operations on 953a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner /// non-legal value types are not described here. 954a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner uint64_t OpActions[156]; 955a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner 9560d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner /// LoadXActions - For each load of load extension type and each value type, 9570d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner /// keep a LegalizeAction that indicates how instruction selection should deal 9580d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner /// with the load. 9590d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner uint64_t LoadXActions[ISD::LAST_LOADX_TYPE]; 9600d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner 9610d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner /// StoreXActions - For each store with truncation of each value type, keep a 9620d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner /// LegalizeAction that indicates how instruction selection should deal with 9630d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner /// the store. 9640d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner uint64_t StoreXActions; 9650d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner 9660d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner /// IndexedModeActions - For each indexed mode and each value type, keep a 9670d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner /// pair of LegalizeAction that indicates how instruction selection should 9680d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner /// deal with the load / store. 9690d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner uint64_t IndexedModeActions[2][ISD::LAST_INDEXED_MODE]; 9700d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner 9710d8db8e0a8492ab2d4bef725ec61b519471b97ecChris Lattner ValueTypeActionImpl ValueTypeActions; 972a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner 973a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner std::vector<double> LegalFPImmediates; 974a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner 975a599de241041eebc84867ac8e4cb76668cabd236Chris Lattner std::vector<std::pair<MVT::ValueType, 976b779033a23c49c2e5e02b15a87bbae42973287b3Chris Lattner TargetRegisterClass*> > AvailableRegClasses; 977b779033a23c49c2e5e02b15a87bbae42973287b3Chris Lattner 978b779033a23c49c2e5e02b15a87bbae42973287b3Chris Lattner /// TargetDAGCombineArray - Targets can specify ISD nodes that they would 979b779033a23c49c2e5e02b15a87bbae42973287b3Chris Lattner /// like PerformDAGCombine callbacks for by calling setTargetDAGCombine(), 98082ed17eb472102cb6711b832183ee4816ad9a656Chris Lattner /// which sets a bit in this array. 98196716c7b92cfdbc433836e8911335a4832b72b5bBruno Cardoso Lopes unsigned char TargetDAGCombineArray[156/(sizeof(unsigned char)*8)]; 9828b0f7a7d8627392c8faae3801cc91689406960cfChris Lattner 9838b0f7a7d8627392c8faae3801cc91689406960cfChris Lattner /// PromoteToType - For operations that must be promoted to a specific type, 98407de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes /// this holds the destination type. This map should be sparse, so don't hold 98507de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes /// it as an array. 98607de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes /// 987e943c15621035fa7fbeda7b4922d06a8c2b05b2dBruno Cardoso Lopes /// Targets add entries to this map with AddPromotedToType(..), clients access 98807de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes /// this with getTypeToPromoteTo(..). 98907de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes std::map<std::pair<unsigned, MVT::ValueType>, MVT::ValueType> PromoteToType; 99007de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes 99107de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes /// LibcallRoutineNames - Stores the name each libcall. 99207de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes /// 99307de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes const char *LibcallRoutineNames[RTLIB::UNKNOWN_LIBCALL]; 99407de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes 995a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindolaprotected: 996a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindola /// When lowering %llvm.memset this field specifies the maximum number of 997a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindola /// store operations that may be substituted for the call to memset. Targets 998a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindola /// must set this value based on the cost threshold for that target. Targets 999a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindola /// should assume that the memset will be done using as many of the largest 1000a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindola /// store operations first, followed by smaller ones, if necessary, per 100107de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes /// alignment restrictions. For example, storing 9 bytes on a 32-bit machine 1002a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindola /// with 16-bit alignment would result in four 2-byte stores and one 1-byte 100307de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes /// store. This only applies to setting a constant array of a constant size. 1004a8c02c3bdd68e65d14fb6b0d56989663754059b0Rafael Espindola /// @brief Specify maximum number of store instructions per memset call. 100507de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes unsigned maxStoresPerMemset; 100607de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes 1007548abfcbd671b1144bf517b17643259dcae76f4fChris Lattner /// When lowering %llvm.memcpy this field specifies the maximum number of 1008548abfcbd671b1144bf517b17643259dcae76f4fChris Lattner /// store operations that may be substituted for a call to memcpy. Targets 1009548abfcbd671b1144bf517b17643259dcae76f4fChris Lattner /// must set this value based on the cost threshold for that target. Targets 101007de40629f73fb018a2a7f0a5bbd1ee4defe95fdBruno Cardoso Lopes /// should assume that the memcpy will be done using as many of the largest 101128249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// store operations first, followed by smaller ones, if necessary, per 101282ed17eb472102cb6711b832183ee4816ad9a656Chris Lattner /// alignment restrictions. For example, storing 7 bytes on a 32-bit machine 101382ed17eb472102cb6711b832183ee4816ad9a656Chris Lattner /// with 32-bit alignment would result in one 4-byte store, a one 2-byte store 101428249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// and one 1-byte store. This only applies to copying a constant array of 101528249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// constant size. 101628249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// @brief Specify maximum bytes of store instructions per memcpy call. 101728249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner unsigned maxStoresPerMemcpy; 101828249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner 101928249d98e195f7e04709b959e9f8ffe0d8080bf2Chris Lattner /// When lowering %llvm.memmove this field specifies the maximum number of 1020457624792803e26136889b8cf17e8aa7b84e58b4Chris Lattner /// store instructions that may be substituted for a call to memmove. Targets 1021 /// must set this value based on the cost threshold for that target. Targets 1022 /// should assume that the memmove will be done using as many of the largest 1023 /// store operations first, followed by smaller ones, if necessary, per 1024 /// alignment restrictions. For example, moving 9 bytes on a 32-bit machine 1025 /// with 8-bit alignment would result in nine 1-byte stores. This only 1026 /// applies to copying a constant array of constant size. 1027 /// @brief Specify maximum bytes of store instructions per memmove call. 1028 unsigned maxStoresPerMemmove; 1029 1030 /// This field specifies whether the target machine permits unaligned memory 1031 /// accesses. This is used, for example, to determine the size of store 1032 /// operations when copying small arrays and other similar tasks. 1033 /// @brief Indicate whether the target permits unaligned memory accesses. 1034 bool allowUnalignedMemoryAccesses; 1035}; 1036} // end llvm namespace 1037 1038#endif 1039