Go to the documentation of this file.
51 switch (operand.
type()) {
72 return "unsigned long";
86 std::ostream& os, std::string& opName,
const Operation& op,
87 mode macroMode,
bool legacy) {
89 if (macroMode ==
RISCV) {
102 os <<
"#define _TCE";
107 const std::string outputOperandName =
108 legacy ?
"__tce_op_output_" :
"__oa_op_output_";
112 os <<
"_RV_" << opName <<
"(";
115 os <<
"FU_" << opName <<
"(FU, ";
118 os <<
"AS_" << opName <<
"(AS, ";
121 os <<
"_" << opName <<
"(";
135 os <<
"i" << seenInputs;
138 os <<
"o" << seenOutputs;
174 if (operandTypeString !=
"" && !operand.
isVector()) {
180 std::string volatileKeyword =
"";
183 volatileKeyword =
"volatile ";
186 os <<
"asm " << volatileKeyword <<
"(";
190 os <<
"\"//" << opName <<
" ";
194 os <<
"\\%" << std::to_string(iterations) <<
" ";
197 os <<
"\\%" << std::to_string(iterations + i);
204 os <<
"\"_AS.\" AS\".";
211 if (macroMode !=
RISCV) {
222 os <<
"\"=r\"( " << outputOperandName << out <<
")";
224 os <<
"\"=r\"(o" << out <<
")";
235 if (macroMode ==
RISCV) {
240 os <<
"\"r\"(i" << in <<
")";
244 <<
")(i" << in <<
"))";
247 os <<
"\"r\"(i" << in <<
")";
249 os <<
"\"ir\"(i" << in <<
")";
260 os <<
"o" << out <<
" = " << outputOperandName << out <<
";";
264 os <<
"} while(0) " << std::endl;
276 std::set<std::string> operations;
282 for (
int o = 0; o < opCount; o++) {
285 if (operations.count(opName) > 0) {
289 operations.insert(opName);
315 int main(
int argc,
char* argv[]) {
317 if (!(argc == 1 || argc == 3) ||
320 std::cout <<
"Usage: tceopgen" << std::endl
321 <<
" -o Output File." << std::endl;
327 }
else if (argc == 3) {
328 std::ofstream customops;
329 customops.open(argv[2]);
330 if (!customops.good()) {
331 std::cerr <<
"Error opening '" << argv[2]
332 <<
"' for writing." << std::endl;
virtual int affectedByCount() const
virtual bool writesMemory() const
Operation & operation(const char *name)
virtual bool hasSideEffects() const
virtual Operand & output(int index) const
virtual int numberOfInputs() const
void writeCustomOpMacro(std::ostream &os, std::string &opName, const Operation &op, mode macroMode, bool legacy)
static std::string toString(const T &source)
int main(int argc, char *argv[])
void writeCustomOpMacros(std::ostream &os)
#define assert(condition)
virtual bool isVector() const
std::string errorMessage() const
virtual Operand & input(int index) const
virtual bool usesMemory() const
virtual Operand & operand(int id) const
static std::ostream & errorStream()
virtual OperandType type() const
std::string operandTypeCString(const Operand &operand)
virtual bool isInput() const
int operationCount(const OperationModule &om)
virtual int numberOfOutputs() const
OperationModule & module(int i)
virtual int affectsCount() const
std::string operationName(int i, const OperationModule &om)