mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-13 22:58:50 +00:00
Compute the value types that are natively supported by a target.
llvm-svn: 23282
This commit is contained in:
parent
152a72de2c
commit
e2fb8f3a77
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "llvm/CodeGen/ValueTypes.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class Record;
|
class Record;
|
||||||
@ -36,6 +37,7 @@ namespace llvm {
|
|||||||
std::vector<Record*> Elements;
|
std::vector<Record*> Elements;
|
||||||
unsigned SpillSize;
|
unsigned SpillSize;
|
||||||
unsigned SpillAlignment;
|
unsigned SpillAlignment;
|
||||||
|
MVT::ValueType VT;
|
||||||
std::string MethodProtos, MethodBodies;
|
std::string MethodProtos, MethodBodies;
|
||||||
|
|
||||||
const std::string &getName() const;
|
const std::string &getName() const;
|
||||||
|
@ -152,6 +152,7 @@ CodeGenRegisterClass::CodeGenRegisterClass(Record *R) : TheDef(R) {
|
|||||||
Namespace = R->getValueAsString("Namespace");
|
Namespace = R->getValueAsString("Namespace");
|
||||||
SpillSize = R->getValueAsInt("Size");
|
SpillSize = R->getValueAsInt("Size");
|
||||||
SpillAlignment = R->getValueAsInt("Alignment");
|
SpillAlignment = R->getValueAsInt("Alignment");
|
||||||
|
VT = getValueType(R->getValueAsDef("RegType"));
|
||||||
|
|
||||||
if (CodeInit *CI = dynamic_cast<CodeInit*>(R->getValueInit("MethodBodies")))
|
if (CodeInit *CI = dynamic_cast<CodeInit*>(R->getValueInit("MethodBodies")))
|
||||||
MethodBodies = CI->getValue();
|
MethodBodies = CI->getValue();
|
||||||
@ -182,6 +183,11 @@ const std::string &CodeGenRegisterClass::getName() const {
|
|||||||
return TheDef->getName();
|
return TheDef->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CodeGenTarget::ReadLegalValueTypes() const {
|
||||||
|
const std::vector<CodeGenRegisterClass> &RCs = getRegisterClasses();
|
||||||
|
for (unsigned i = 0, e = RCs.size(); i != e; ++i)
|
||||||
|
LegalValueTypes.push_back(RCs[i].VT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CodeGenTarget::ReadInstructions() const {
|
void CodeGenTarget::ReadInstructions() const {
|
||||||
|
@ -47,9 +47,11 @@ class CodeGenTarget {
|
|||||||
mutable std::map<std::string, CodeGenInstruction> Instructions;
|
mutable std::map<std::string, CodeGenInstruction> Instructions;
|
||||||
mutable std::vector<CodeGenRegister> Registers;
|
mutable std::vector<CodeGenRegister> Registers;
|
||||||
mutable std::vector<CodeGenRegisterClass> RegisterClasses;
|
mutable std::vector<CodeGenRegisterClass> RegisterClasses;
|
||||||
|
mutable std::vector<MVT::ValueType> LegalValueTypes;
|
||||||
void ReadRegisters() const;
|
void ReadRegisters() const;
|
||||||
void ReadRegisterClasses() const;
|
void ReadRegisterClasses() const;
|
||||||
void ReadInstructions() const;
|
void ReadInstructions() const;
|
||||||
|
void ReadLegalValueTypes() const;
|
||||||
public:
|
public:
|
||||||
CodeGenTarget();
|
CodeGenTarget();
|
||||||
|
|
||||||
@ -70,16 +72,29 @@ public:
|
|||||||
///
|
///
|
||||||
Record *getAsmWriter() const;
|
Record *getAsmWriter() const;
|
||||||
|
|
||||||
const std::vector<CodeGenRegister> &getRegisters() {
|
const std::vector<CodeGenRegister> &getRegisters() const {
|
||||||
if (Registers.empty()) ReadRegisters();
|
if (Registers.empty()) ReadRegisters();
|
||||||
return Registers;
|
return Registers;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CodeGenRegisterClass> getRegisterClasses() {
|
const std::vector<CodeGenRegisterClass> &getRegisterClasses() const {
|
||||||
if (RegisterClasses.empty()) ReadRegisterClasses();
|
if (RegisterClasses.empty()) ReadRegisterClasses();
|
||||||
return RegisterClasses;
|
return RegisterClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<MVT::ValueType> &getLegalValueTypes() const {
|
||||||
|
if (LegalValueTypes.empty()) ReadLegalValueTypes();
|
||||||
|
return LegalValueTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// isLegalValueType - Return true if the specified value type is natively
|
||||||
|
/// supported by the target (i.e. there are registers that directly hold it).
|
||||||
|
bool isLegalValueType(MVT::ValueType VT) const {
|
||||||
|
const std::vector<MVT::ValueType> &LegalVTs = getLegalValueTypes();
|
||||||
|
for (unsigned i = 0, e = LegalVTs.size(); i != e; ++i)
|
||||||
|
if (LegalVTs[i] == VT) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// getInstructions - Return all of the instructions defined for this target.
|
/// getInstructions - Return all of the instructions defined for this target.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user