51 switch (operand.
type()) {
72 return "unsigned long";
86 std::ostream& os, std::string& opName,
const Operation& op,
87 mode macroMode,
bool legacy) {
98 const std::string outputOperandName =
99 legacy ?
"__tce_op_output_" :
"__oa_op_output_";
103 os <<
"_RV_" << opName <<
"(";
106 os <<
"FU_" << opName <<
"(FU, ";
109 os <<
"AS_" << opName <<
"(AS, ";
112 os <<
"_" << opName <<
"(";
126 os <<
"i" << seenInputs;
129 os <<
"o" << seenOutputs;
165 if (operandTypeString !=
"" && !operand.
isVector()) {
171 std::string volatileKeyword =
"";
174 volatileKeyword =
"volatile ";
177 os <<
"asm " << volatileKeyword <<
"(";
182 os <<
"\"OA_" << opName <<
" ";
186 os <<
"%" << std::to_string(iterations);
192 os <<
", %" << std::to_string(iterations + i);
199 os <<
"\"_AS.\" AS\".";
206 if (macroMode !=
RISCV) {
217 os <<
"\"=r\"( " << outputOperandName << out <<
")";
219 os <<
"\"=r\"(o" << out <<
")";
230 if (macroMode ==
RISCV) {
235 os <<
"\"r\"(i" << in <<
")";
239 <<
")(i" << in <<
"))";
242 os <<
"\"r\"(i" << in <<
")";
244 os <<
"\"ir\"(i" << in <<
")";
255 os <<
"o" << out <<
" = " << outputOperandName << out <<
";";
259 os <<
"} while(0) " << std::endl;
271 std::set<std::string> operations;
277 for (
int o = 0; o < opCount; o++) {
280 if (operations.count(opName) > 0) {
283 const Operation& op = pool.operation(opName.c_str());
284 operations.insert(opName);
310int main(
int argc,
char* argv[]) {
312 if (!(argc == 1 || argc == 3) ||
315 std::cout <<
"Usage: tceopgen" << std::endl
316 <<
" -o Output File." << std::endl;
322 }
else if (argc == 3) {
323 std::ofstream customops;
324 customops.open(argv[2]);
325 if (!customops.good()) {
326 std::cerr <<
"Error opening '" << argv[2]
327 <<
"' for writing." << std::endl;
#define assert(condition)
static std::ostream & errorStream()
static std::string toString(const T &source)
std::string errorMessage() const
virtual bool isVector() const
virtual bool isInput() const
virtual OperandType type() const
std::string operationName(int i, const OperationModule &om)
OperationModule & module(int i)
int operationCount(const OperationModule &om)
virtual int affectedByCount() const
virtual bool usesMemory() const
virtual Operand & output(int index) const
virtual Operand & input(int index) const
virtual bool hasSideEffects() const
virtual int affectsCount() const
virtual bool writesMemory() const
virtual int numberOfInputs() const
virtual int numberOfOutputs() const
virtual Operand & operand(int id) const
int main(int argc, char *argv[])
void writeCustomOpMacros(std::ostream &os)
void writeCustomOpMacro(std::ostream &os, std::string &opName, const Operation &op, mode macroMode, bool legacy)
std::string operandTypeCString(const Operand &operand)