86 auto fn = dyn_cast<::cir::FuncOp>(op);
95 if (!annotated.Success) {
96 llvm::errs() <<
"error: function '" << fn.getSymName() <<
"' has invalid annotations\n";
100 const auto args = fn.getArguments();
102 std::vector<std::string> argNames = GetArgNames(fn);
104 if (args.size() != argNames.size()) {
105 llvm::errs() <<
"error: invalid function signature for '" << fn.getSymName() <<
"' (annotation mismatched)\n";
109 auto copyPath = annotated.Path;
112 llvm::errs() <<
"error: couldn't create symbol node (";
113 for (
auto seg : annotated.Path) {
114 llvm::errs() <<
'/' << seg;
116 llvm::errs() <<
"). is there a invalid path for symbol?\n";
120 fnSym->
attributes().emplace_back(std::make_pair(
"sym", fn.getSymName()));
122 const auto rets = fn.getResultTypes();
125 if (rets.size() > 0) {
128 llvm::errs() <<
"error: unrecognized return type '";
129 rets[0].print(llvm::errs());
130 llvm::errs() <<
"'\n";
133 typeStr = type->store(symbols);
138 fnSym->attributes().emplace_back(std::make_pair(
"ret", typeStr));
143 annotated.Path.pop_back();
145 assert(parentNode &&
"parent of a symbol cannot be null");
154 for (; iParm < args.size(); ++iParm) {
155 auto type =
Types::From(args[iParm].getType(), module);
157 llvm::errs() <<
"error: unrecognized type '";
158 args[iParm].getType().print(llvm::errs());
159 llvm::errs() <<
"'\n";
162 const auto typeStr = type->store(symbols);
166 .emplace_back(
"param", argNames[iParm])
168 .emplace_back(
"type", typeStr);