Lines Matching full:os
51 void run(raw_ostream &OS, bool Enums);
53 void EmitEnumInfo(const CodeGenIntrinsicTable &Ints, raw_ostream &OS);
54 void EmitArgKind(raw_ostream &OS);
55 void EmitIITInfo(raw_ostream &OS);
56 void EmitTargetInfo(const CodeGenIntrinsicTable &Ints, raw_ostream &OS);
58 raw_ostream &OS);
60 raw_ostream &OS);
61 void EmitGenerator(const CodeGenIntrinsicTable &Ints, raw_ostream &OS);
62 void EmitAttributes(const CodeGenIntrinsicTable &Ints, raw_ostream &OS);
64 bool IsClang, raw_ostream &OS);
72 void IntrinsicEmitter::run(raw_ostream &OS, bool Enums) {
73 emitSourceFileHeader("Intrinsic Function Source Fragment", OS);
79 EmitEnumInfo(Ints, OS);
82 EmitArgKind(OS);
85 EmitIITInfo(OS);
88 EmitTargetInfo(Ints, OS);
91 EmitIntrinsicToNameTable(Ints, OS);
94 EmitIntrinsicToOverloadTable(Ints, OS);
97 EmitGenerator(Ints, OS);
100 EmitAttributes(Ints, OS);
103 EmitIntrinsicToBuiltinMap(Ints, true, OS);
106 EmitIntrinsicToBuiltinMap(Ints, false, OS);
111 raw_ostream &OS) {
134 OS << "#ifdef GET_INTRINSIC_ENUM_VALUES\n";
137 OS << "#ifndef LLVM_IR_INTRINSIC_" << UpperPrefix << "_ENUMS_H\n";
138 OS << "#define LLVM_IR_INTRINSIC_" << UpperPrefix << "_ENUMS_H\n\n";
139 OS << "namespace llvm {\n";
140 OS << "namespace Intrinsic {\n";
141 OS << "enum " << UpperPrefix << "Intrinsics : unsigned {\n";
144 OS << "// Enum values for intrinsics\n";
146 OS << " " << Ints[i].EnumName;
151 OS << " = " << (Set->Offset + 1);
153 OS << ", ";
155 OS.indent(40 - Ints[i].EnumName.size());
156 OS << " // " << Ints[i].Name << "\n";
161 OS << " num_intrinsics = " << (Ints.size() + 1) << "\n";
162 OS << "#endif\n\n";
164 OS << "}; // enum\n";
165 OS << "} // namespace Intrinsic\n";
166 OS << "} // namespace llvm\n\n";
167 OS << "#endif\n";
171 void IntrinsicEmitter::EmitArgKind(raw_ostream &OS) {
174 OS << "// llvm::Intrinsic::IITDescriptor::ArgKind\n";
175 OS << "#ifdef GET_INTRINSIC_ARGKIND\n";
178 OS << " AK_" << RV.getName() << " = " << *RV.getValue() << ",\n";
180 OS << "#error \"ArgKind is not defined\"\n";
182 OS << "#endif\n\n";
185 void IntrinsicEmitter::EmitIITInfo(raw_ostream &OS) {
186 OS << "#ifdef GET_INTRINSIC_IITINFO\n";
199 OS << " " << RecsByNumber[I] << " = " << I << ",\n";
201 OS << "#error \"class IIT_Base is not defined\"\n";
203 OS << "#endif\n\n";
207 raw_ostream &OS) {
208 OS << "// Target mapping\n";
209 OS << "#ifdef GET_INTRINSIC_TARGET_DATA\n";
210 OS << "struct IntrinsicTargetInfo {\n"
215 OS << "static constexpr IntrinsicTargetInfo TargetInfos[] = {\n";
217 OS << " {llvm::StringLiteral(\"" << Target.Name << "\"), " << Target.Offset
219 OS << "};\n";
220 OS << "#endif\n\n";
224 const CodeGenIntrinsicTable &Ints, raw_ostream &OS) {
225 OS << "// Intrinsic ID to name table\n";
226 OS << "#ifdef GET_INTRINSIC_NAME_TABLE\n";
227 OS << " // Note that entry #0 is the invalid intrinsic!\n";
229 OS << " \"" << Ints[i].Name << "\",\n";
230 OS << "#endif\n\n";
234 const CodeGenIntrinsicTable &Ints, raw_ostream &OS) {
235 OS << "// Intrinsic ID to overload bitset\n";
236 OS << "#ifdef GET_INTRINSIC_OVERLOAD_TABLE\n";
237 OS << "static const uint8_t OTable[] = {\n";
238 OS << " 0";
242 OS << ",\n 0";
244 OS << " | (1<<" << (i + 1) % 8 << ')';
246 OS << "\n};\n\n";
248 OS << "return (OTable[id/8] & (1 << (id%8))) != 0;\n";
249 OS << "#endif\n\n";
264 static void printIITEntry(raw_ostream &OS, unsigned char X) {
265 OS << (unsigned)X;
269 raw_ostream &OS) {
315 OS << "// Global intrinsic function declaration type table.\n";
316 OS << "#ifdef GET_INTRINSIC_GENERATOR_GLOBAL\n";
318 OS << "static const unsigned IIT_Table[] = {\n ";
322 OS << "\n ";
326 OS << "0x" << Twine::utohexstr(FixedEncodings[i]) << ", ";
335 OS << "(1U<<31) | " << LongEncodingTable.get(TypeSig) << ", ";
338 OS << "0\n};\n\n";
341 OS << "static const unsigned char IIT_LongEncodingTable[] = {\n";
343 LongEncodingTable.emit(OS, printIITEntry);
344 OS << " 255\n};\n\n";
346 OS << "#endif\n\n"; // End of GET_INTRINSIC_GENERATOR_GLOBAL
421 raw_ostream &OS) {
422 OS << "// Add parameter attributes that are not common to all intrinsics.\n";
423 OS << "#ifdef GET_INTRINSIC_ATTRIBUTES\n";
428 OS << "static AttributeSet getIntrinsicArgAttributeSet("
443 OS << " case " << ID << ":\n";
444 OS << " return AttributeSet::get(C, {\n";
448 OS << " Attribute::get(C, Attribute::NoCapture),\n";
451 OS << " Attribute::get(C, Attribute::NoAlias),\n";
454 OS << " Attribute::get(C, Attribute::NoUndef),\n";
457 OS << " Attribute::get(C, Attribute::NonNull),\n";
460 OS << " Attribute::get(C, Attribute::Returned),\n";
463 OS << " Attribute::get(C, Attribute::ReadOnly),\n";
466 OS << " Attribute::get(C, Attribute::WriteOnly),\n";
469 OS << " Attribute::get(C, Attribute::ReadNone),\n";
472 OS << " Attribute::get(C, Attribute::ImmArg),\n";
475 OS << " Attribute::get(C, Attribute::Alignment, " << Attr.Value
479 OS << " Attribute::get(C, Attribute::Dereferenceable, "
484 OS << " });\n";
487 OS << " }\n";
488 OS << "}\n\n";
493 OS << "static AttributeSet getIntrinsicFnAttributeSet("
502 OS << " case " << ID << ":\n"
505 OS << " Attribute::get(C, Attribute::NoUnwind),\n";
507 OS << " Attribute::get(C, Attribute::NoReturn),\n";
509 OS << " Attribute::get(C, Attribute::NoCallback),\n";
511 OS << " Attribute::get(C, Attribute::NoSync),\n";
513 OS << " Attribute::get(C, Attribute::NoFree),\n";
515 OS << " Attribute::get(C, Attribute::WillReturn),\n";
517 OS << " Attribute::get(C, Attribute::Cold),\n";
519 OS << " Attribute::get(C, Attribute::NoDuplicate),\n";
521 OS << " Attribute::get(C, Attribute::NoMerge),\n";
523 OS << " Attribute::get(C, Attribute::Convergent),\n";
525 OS << " Attribute::get(C, Attribute::Speculatable),\n";
527 OS << " Attribute::get(C, Attribute::StrictFP),\n";
534 OS << " Attribute::getWithMemoryEffects(C, "
537 OS << " });\n";
539 OS << " }\n";
540 OS << "}\n\n";
541 OS << "AttributeList Intrinsic::getAttributes(LLVMContext &C, ID id) {\n";
562 OS << " static const uint16_t IntrinsicsToAttributesMap[] = {\n";
567 OS << " " << UniqAttributes[&intrinsic] << ", // " << intrinsic.Name
570 OS << " };\n\n";
572 OS << " std::pair<unsigned, AttributeSet> AS[" << maxArgAttrs + 1 << "];\n";
573 OS << " unsigned NumAttrs = 0;\n";
574 OS << " if (id != 0) {\n";
575 OS << " switch(IntrinsicsToAttributesMap[id - 1]) {\n";
576 OS << " default: llvm_unreachable(\"Invalid attribute number\");\n";
578 OS << " case " << UniqAttribute.second << ": {\n";
591 OS << " AS[" << numAttrs++ << "] = {" << AttrIdx
604 OS << " AS[" << numAttrs++ << "] = {AttributeList::FunctionIndex, "
609 OS << " NumAttrs = " << numAttrs << ";\n";
610 OS << " break;\n";
611 OS << " }\n";
613 OS << " return AttributeList();\n";
614 OS << " }\n";
618 OS << " }\n";
619 OS << " }\n";
620 OS << " return AttributeList::get(C, ArrayRef(AS, NumAttrs));\n";
621 OS << "}\n";
622 OS << "#endif // GET_INTRINSIC_ATTRIBUTES\n\n";
626 const CodeGenIntrinsicTable &Ints, bool IsClang, raw_ostream &OS) {
648 OS << "// Get the LLVM intrinsic that corresponds to a builtin.\n";
649 OS << "// This is used by the C front-end. The builtin name is passed\n";
650 OS << "// in as BuiltinName, and a target prefix (e.g. 'ppc') is passed\n";
651 OS << "// in as TargetPrefix. The result is assigned to 'IntrinsicID'.\n";
652 OS << "#ifdef GET_LLVM_INTRINSIC_FOR_" << UpperCompilerName << "_BUILTIN\n";
654 OS << "Intrinsic::ID Intrinsic::getIntrinsicFor" << CompilerName
659 OS << " return Intrinsic::not_intrinsic;\n";
660 OS << "}\n";
661 OS << "#endif\n\n";
665 OS << " static const char BuiltinNames[] = {\n";
666 Table.EmitCharArray(OS);
667 OS << " };\n\n";
669 OS << " struct BuiltinEntry {\n";
670 OS << " Intrinsic::ID IntrinID;\n";
671 OS << " unsigned StrTabOffset;\n";
672 OS << " const char *getName() const {\n";
673 OS << " return &BuiltinNames[StrTabOffset];\n";
674 OS << " }\n";
675 OS << " bool operator<(StringRef RHS) const {\n";
676 OS << " return strncmp(getName(), RHS.data(), RHS.size()) < 0;\n";
677 OS << " }\n";
678 OS << " };\n";
680 OS << " StringRef TargetPrefix(TargetPrefixStr);\n\n";
684 OS << " ";
686 OS << "if (TargetPrefix == \"" << I.first << "\") ";
688 OS << "/* Target Independent Builtins */ ";
689 OS << "{\n";
692 OS << " static const BuiltinEntry " << I.first << "Names[] = {\n";
694 OS << " {Intrinsic::" << P.second << ", "
697 OS << " };\n";
698 OS << " auto I = std::lower_bound(std::begin(" << I.first << "Names),\n";
699 OS << " std::end(" << I.first << "Names),\n";
700 OS << " BuiltinNameStr);\n";
701 OS << " if (I != std::end(" << I.first << "Names) &&\n";
702 OS << " I->getName() == BuiltinNameStr)\n";
703 OS << " return I->IntrinID;\n";
704 OS << " }\n";
706 OS << " return ";
707 OS << "Intrinsic::not_intrinsic;\n";
708 OS << "}\n";
709 OS << "#endif\n\n";
712 static void EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS) {
713 IntrinsicEmitter(RK).run(OS, /*Enums=*/true);
719 static void EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS) {
720 IntrinsicEmitter(RK).run(OS, /*Enums=*/false);