mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-26 21:32:10 +00:00
Initial checkin of useful wrappers around the Target classes, for now, only ValueType and
Target are wrapped git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7665 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1a737c8366
commit
4587207967
66
support/tools/TableGen/CodeGenWrappers.cpp
Normal file
66
support/tools/TableGen/CodeGenWrappers.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
//===- CodeGenWrappers.cpp - Code Generation Class Wrappers -----*- C++ -*-===//
|
||||
//
|
||||
// These classes wrap target description classes used by the various code
|
||||
// generation TableGen backends. This makes it easier to access the data and
|
||||
// provides a single place that needs to check it for validity. All of these
|
||||
// classes throw exceptions on error conditions.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "CodeGenWrappers.h"
|
||||
#include "Record.h"
|
||||
|
||||
/// getValueType - Return the MCV::ValueType that the specified TableGen record
|
||||
/// corresponds to.
|
||||
MVT::ValueType getValueType(Record *Rec) {
|
||||
return (MVT::ValueType)Rec->getValueAsInt("Value");
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &OS, MVT::ValueType T) {
|
||||
switch (T) {
|
||||
case MVT::Other: return OS << "UNKNOWN";
|
||||
case MVT::i1: return OS << "i1";
|
||||
case MVT::i8: return OS << "i8";
|
||||
case MVT::i16: return OS << "i16";
|
||||
case MVT::i32: return OS << "i32";
|
||||
case MVT::i64: return OS << "i64";
|
||||
case MVT::i128: return OS << "i128";
|
||||
case MVT::f32: return OS << "f32";
|
||||
case MVT::f64: return OS << "f64";
|
||||
case MVT::f80: return OS << "f80";
|
||||
case MVT::f128: return OS << "f128";
|
||||
case MVT::isVoid:return OS << "void";
|
||||
}
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// getTarget - Return the current instance of the Target class.
|
||||
///
|
||||
CodeGenTarget::CodeGenTarget() {
|
||||
std::vector<Record*> Targets = Records.getAllDerivedDefinitions("Target");
|
||||
if (Targets.size() != 1)
|
||||
throw std::string("ERROR: Multiple subclasses of Target defined!");
|
||||
TargetRec = Targets[0];
|
||||
|
||||
// Read in all of the CalleeSavedRegisters...
|
||||
ListInit *LI = TargetRec->getValueAsListInit("CalleeSavedRegisters");
|
||||
for (unsigned i = 0, e = LI->getSize(); i != e; ++i)
|
||||
if (DefInit *DI = dynamic_cast<DefInit*>(LI->getElement(i)))
|
||||
CalleeSavedRegisters.push_back(DI->getDef());
|
||||
else
|
||||
throw "Target: " + TargetRec->getName() +
|
||||
" expected register definition in CalleeSavedRegisters list!";
|
||||
|
||||
PointerType = getValueType(TargetRec->getValueAsDef("PointerType"));
|
||||
}
|
||||
|
||||
|
||||
const std::string &CodeGenTarget::getName() const {
|
||||
return TargetRec->getName();
|
||||
}
|
||||
|
||||
Record *CodeGenTarget::getInstructionSet() const {
|
||||
return TargetRec->getValueAsDef("InstructionSet");
|
||||
}
|
52
support/tools/TableGen/CodeGenWrappers.h
Normal file
52
support/tools/TableGen/CodeGenWrappers.h
Normal file
@ -0,0 +1,52 @@
|
||||
//===- CodeGenWrappers.h - Code Generation Class Wrappers -------*- C++ -*-===//
|
||||
//
|
||||
// These classes wrap target description classes used by the various code
|
||||
// generation TableGen backends. This makes it easier to access the data and
|
||||
// provides a single place that needs to check it for validity. All of these
|
||||
// classes throw exceptions on error conditions.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef CODEGENWRAPPERS_H
|
||||
#define CODEGENWRAPPERS_H
|
||||
|
||||
#include "llvm/CodeGen/ValueTypes.h"
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
class Record;
|
||||
class RecordKeeper;
|
||||
|
||||
/// getValueType - Return the MVT::ValueType that the specified TableGen record
|
||||
/// corresponds to.
|
||||
MVT::ValueType getValueType(Record *Rec);
|
||||
|
||||
std::ostream &operator<<(std::ostream &OS, MVT::ValueType T);
|
||||
|
||||
|
||||
|
||||
/// CodeGenTarget - This class corresponds to the Target class in the .td files.
|
||||
///
|
||||
class CodeGenTarget {
|
||||
Record *TargetRec;
|
||||
std::vector<Record*> CalleeSavedRegisters;
|
||||
MVT::ValueType PointerType;
|
||||
|
||||
public:
|
||||
CodeGenTarget();
|
||||
|
||||
Record *getTargetRecord() const { return TargetRec; }
|
||||
const std::string &getName() const;
|
||||
|
||||
const std::vector<Record*> &getCalleeSavedRegisters() const {
|
||||
return CalleeSavedRegisters;
|
||||
}
|
||||
|
||||
// getInstructionSet - Return the InstructionSet object...
|
||||
Record *getInstructionSet() const;
|
||||
|
||||
// getInstructionSet - Return the CodeGenInstructionSet object for this
|
||||
// target, lazily reading it from the record keeper as needed.
|
||||
// CodeGenInstructionSet *getInstructionSet -
|
||||
};
|
||||
|
||||
#endif
|
66
utils/TableGen/CodeGenTarget.cpp
Normal file
66
utils/TableGen/CodeGenTarget.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
//===- CodeGenWrappers.cpp - Code Generation Class Wrappers -----*- C++ -*-===//
|
||||
//
|
||||
// These classes wrap target description classes used by the various code
|
||||
// generation TableGen backends. This makes it easier to access the data and
|
||||
// provides a single place that needs to check it for validity. All of these
|
||||
// classes throw exceptions on error conditions.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "CodeGenWrappers.h"
|
||||
#include "Record.h"
|
||||
|
||||
/// getValueType - Return the MCV::ValueType that the specified TableGen record
|
||||
/// corresponds to.
|
||||
MVT::ValueType getValueType(Record *Rec) {
|
||||
return (MVT::ValueType)Rec->getValueAsInt("Value");
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &OS, MVT::ValueType T) {
|
||||
switch (T) {
|
||||
case MVT::Other: return OS << "UNKNOWN";
|
||||
case MVT::i1: return OS << "i1";
|
||||
case MVT::i8: return OS << "i8";
|
||||
case MVT::i16: return OS << "i16";
|
||||
case MVT::i32: return OS << "i32";
|
||||
case MVT::i64: return OS << "i64";
|
||||
case MVT::i128: return OS << "i128";
|
||||
case MVT::f32: return OS << "f32";
|
||||
case MVT::f64: return OS << "f64";
|
||||
case MVT::f80: return OS << "f80";
|
||||
case MVT::f128: return OS << "f128";
|
||||
case MVT::isVoid:return OS << "void";
|
||||
}
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// getTarget - Return the current instance of the Target class.
|
||||
///
|
||||
CodeGenTarget::CodeGenTarget() {
|
||||
std::vector<Record*> Targets = Records.getAllDerivedDefinitions("Target");
|
||||
if (Targets.size() != 1)
|
||||
throw std::string("ERROR: Multiple subclasses of Target defined!");
|
||||
TargetRec = Targets[0];
|
||||
|
||||
// Read in all of the CalleeSavedRegisters...
|
||||
ListInit *LI = TargetRec->getValueAsListInit("CalleeSavedRegisters");
|
||||
for (unsigned i = 0, e = LI->getSize(); i != e; ++i)
|
||||
if (DefInit *DI = dynamic_cast<DefInit*>(LI->getElement(i)))
|
||||
CalleeSavedRegisters.push_back(DI->getDef());
|
||||
else
|
||||
throw "Target: " + TargetRec->getName() +
|
||||
" expected register definition in CalleeSavedRegisters list!";
|
||||
|
||||
PointerType = getValueType(TargetRec->getValueAsDef("PointerType"));
|
||||
}
|
||||
|
||||
|
||||
const std::string &CodeGenTarget::getName() const {
|
||||
return TargetRec->getName();
|
||||
}
|
||||
|
||||
Record *CodeGenTarget::getInstructionSet() const {
|
||||
return TargetRec->getValueAsDef("InstructionSet");
|
||||
}
|
52
utils/TableGen/CodeGenTarget.h
Normal file
52
utils/TableGen/CodeGenTarget.h
Normal file
@ -0,0 +1,52 @@
|
||||
//===- CodeGenWrappers.h - Code Generation Class Wrappers -------*- C++ -*-===//
|
||||
//
|
||||
// These classes wrap target description classes used by the various code
|
||||
// generation TableGen backends. This makes it easier to access the data and
|
||||
// provides a single place that needs to check it for validity. All of these
|
||||
// classes throw exceptions on error conditions.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef CODEGENWRAPPERS_H
|
||||
#define CODEGENWRAPPERS_H
|
||||
|
||||
#include "llvm/CodeGen/ValueTypes.h"
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
class Record;
|
||||
class RecordKeeper;
|
||||
|
||||
/// getValueType - Return the MVT::ValueType that the specified TableGen record
|
||||
/// corresponds to.
|
||||
MVT::ValueType getValueType(Record *Rec);
|
||||
|
||||
std::ostream &operator<<(std::ostream &OS, MVT::ValueType T);
|
||||
|
||||
|
||||
|
||||
/// CodeGenTarget - This class corresponds to the Target class in the .td files.
|
||||
///
|
||||
class CodeGenTarget {
|
||||
Record *TargetRec;
|
||||
std::vector<Record*> CalleeSavedRegisters;
|
||||
MVT::ValueType PointerType;
|
||||
|
||||
public:
|
||||
CodeGenTarget();
|
||||
|
||||
Record *getTargetRecord() const { return TargetRec; }
|
||||
const std::string &getName() const;
|
||||
|
||||
const std::vector<Record*> &getCalleeSavedRegisters() const {
|
||||
return CalleeSavedRegisters;
|
||||
}
|
||||
|
||||
// getInstructionSet - Return the InstructionSet object...
|
||||
Record *getInstructionSet() const;
|
||||
|
||||
// getInstructionSet - Return the CodeGenInstructionSet object for this
|
||||
// target, lazily reading it from the record keeper as needed.
|
||||
// CodeGenInstructionSet *getInstructionSet -
|
||||
};
|
||||
|
||||
#endif
|
66
utils/TableGen/CodeGenWrappers.cpp
Normal file
66
utils/TableGen/CodeGenWrappers.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
//===- CodeGenWrappers.cpp - Code Generation Class Wrappers -----*- C++ -*-===//
|
||||
//
|
||||
// These classes wrap target description classes used by the various code
|
||||
// generation TableGen backends. This makes it easier to access the data and
|
||||
// provides a single place that needs to check it for validity. All of these
|
||||
// classes throw exceptions on error conditions.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "CodeGenWrappers.h"
|
||||
#include "Record.h"
|
||||
|
||||
/// getValueType - Return the MCV::ValueType that the specified TableGen record
|
||||
/// corresponds to.
|
||||
MVT::ValueType getValueType(Record *Rec) {
|
||||
return (MVT::ValueType)Rec->getValueAsInt("Value");
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &OS, MVT::ValueType T) {
|
||||
switch (T) {
|
||||
case MVT::Other: return OS << "UNKNOWN";
|
||||
case MVT::i1: return OS << "i1";
|
||||
case MVT::i8: return OS << "i8";
|
||||
case MVT::i16: return OS << "i16";
|
||||
case MVT::i32: return OS << "i32";
|
||||
case MVT::i64: return OS << "i64";
|
||||
case MVT::i128: return OS << "i128";
|
||||
case MVT::f32: return OS << "f32";
|
||||
case MVT::f64: return OS << "f64";
|
||||
case MVT::f80: return OS << "f80";
|
||||
case MVT::f128: return OS << "f128";
|
||||
case MVT::isVoid:return OS << "void";
|
||||
}
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// getTarget - Return the current instance of the Target class.
|
||||
///
|
||||
CodeGenTarget::CodeGenTarget() {
|
||||
std::vector<Record*> Targets = Records.getAllDerivedDefinitions("Target");
|
||||
if (Targets.size() != 1)
|
||||
throw std::string("ERROR: Multiple subclasses of Target defined!");
|
||||
TargetRec = Targets[0];
|
||||
|
||||
// Read in all of the CalleeSavedRegisters...
|
||||
ListInit *LI = TargetRec->getValueAsListInit("CalleeSavedRegisters");
|
||||
for (unsigned i = 0, e = LI->getSize(); i != e; ++i)
|
||||
if (DefInit *DI = dynamic_cast<DefInit*>(LI->getElement(i)))
|
||||
CalleeSavedRegisters.push_back(DI->getDef());
|
||||
else
|
||||
throw "Target: " + TargetRec->getName() +
|
||||
" expected register definition in CalleeSavedRegisters list!";
|
||||
|
||||
PointerType = getValueType(TargetRec->getValueAsDef("PointerType"));
|
||||
}
|
||||
|
||||
|
||||
const std::string &CodeGenTarget::getName() const {
|
||||
return TargetRec->getName();
|
||||
}
|
||||
|
||||
Record *CodeGenTarget::getInstructionSet() const {
|
||||
return TargetRec->getValueAsDef("InstructionSet");
|
||||
}
|
52
utils/TableGen/CodeGenWrappers.h
Normal file
52
utils/TableGen/CodeGenWrappers.h
Normal file
@ -0,0 +1,52 @@
|
||||
//===- CodeGenWrappers.h - Code Generation Class Wrappers -------*- C++ -*-===//
|
||||
//
|
||||
// These classes wrap target description classes used by the various code
|
||||
// generation TableGen backends. This makes it easier to access the data and
|
||||
// provides a single place that needs to check it for validity. All of these
|
||||
// classes throw exceptions on error conditions.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef CODEGENWRAPPERS_H
|
||||
#define CODEGENWRAPPERS_H
|
||||
|
||||
#include "llvm/CodeGen/ValueTypes.h"
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
class Record;
|
||||
class RecordKeeper;
|
||||
|
||||
/// getValueType - Return the MVT::ValueType that the specified TableGen record
|
||||
/// corresponds to.
|
||||
MVT::ValueType getValueType(Record *Rec);
|
||||
|
||||
std::ostream &operator<<(std::ostream &OS, MVT::ValueType T);
|
||||
|
||||
|
||||
|
||||
/// CodeGenTarget - This class corresponds to the Target class in the .td files.
|
||||
///
|
||||
class CodeGenTarget {
|
||||
Record *TargetRec;
|
||||
std::vector<Record*> CalleeSavedRegisters;
|
||||
MVT::ValueType PointerType;
|
||||
|
||||
public:
|
||||
CodeGenTarget();
|
||||
|
||||
Record *getTargetRecord() const { return TargetRec; }
|
||||
const std::string &getName() const;
|
||||
|
||||
const std::vector<Record*> &getCalleeSavedRegisters() const {
|
||||
return CalleeSavedRegisters;
|
||||
}
|
||||
|
||||
// getInstructionSet - Return the InstructionSet object...
|
||||
Record *getInstructionSet() const;
|
||||
|
||||
// getInstructionSet - Return the CodeGenInstructionSet object for this
|
||||
// target, lazily reading it from the record keeper as needed.
|
||||
// CodeGenInstructionSet *getInstructionSet -
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user