llvm.org GIT mirror llvm / cf940ce
whitespace git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193765 91177308-0d34-0410-b5e6-96231b3b80d8 Andrew Trick 7 years ago
5 changed file(s) with 71 addition(s) and 71 deletion(s). Raw diff Collapse all Expand all
896896 ``minsize``
897897 This attribute suggests that optimization passes and code generator
898898 passes make choices that keep the code size of this function as small
899 as possible and perform optimizations that may sacrifice runtime
899 as possible and perform optimizations that may sacrifice runtime
900900 performance in order to minimize the size of the generated code.
901901 ``naked``
902902 This attribute disables prologue / epilogue emission for the
941941 unwind, its runtime behavior is undefined.
942942 ``optnone``
943943 This function attribute indicates that the function is not optimized
944 by any optimization or code generator passes with the
944 by any optimization or code generator passes with the
945945 exception of interprocedural optimization passes.
946946 This attribute cannot be used together with the ``alwaysinline``
947947 attribute; this attribute is also incompatible
948948 with the ``minsize`` attribute and the ``optsize`` attribute.
949
949
950950 The inliner should never inline this function in any situation.
951951 Only functions with the ``alwaysinline`` attribute are valid
952952 candidates for inlining inside the body of this function.
964964 (including ``byval`` arguments) and never changes any state visible
965965 to callers. This means that it cannot unwind exceptions by calling
966966 the ``C++`` exception throwing methods.
967
967
968968 On an argument, this attribute indicates that the function does not
969969 dereference that pointer argument, even though it may read or write the
970970 memory that the pointer points to if accessed through other pointers.
978978 called with the same set of arguments and global state. It cannot
979979 unwind an exception by calling the ``C++`` exception throwing
980980 methods.
981
981
982982 On an argument, this attribute indicates that the function does not write
983983 through this pointer argument, even though it may write to the memory that
984984 the pointer points to.
8383 const Instruction *CurInst;
8484
8585 DenseMap NodeMap;
86
86
8787 /// UnusedArgNodeMap - Maps argument value for unused arguments. This is used
8888 /// to preserve debug information for incoming arguments.
8989 DenseMap UnusedArgNodeMap;
234234 struct JumpTable {
235235 JumpTable(unsigned R, unsigned J, MachineBasicBlock *M,
236236 MachineBasicBlock *D): Reg(R), JTI(J), MBB(M), Default(D) {}
237
237
238238 /// Reg - the virtual register containing the index of the jump table entry
239239 //. to jump to.
240240 unsigned Reg;
513513 FunctionLoweringInfo &FuncInfo;
514514
515515 /// OptLevel - What optimization level we're generating code for.
516 ///
516 ///
517517 CodeGenOpt::Level OptLevel;
518
518
519519 /// GFI - Garbage collection metadata for the function.
520520 GCFunctionInfo *GFI;
521521
597597 assert(N.getNode() == 0 && "Already set a value for this node!");
598598 N = NewN;
599599 }
600
600
601601 void setUnusedArgValue(const Value *V, SDValue NewN) {
602602 SDValue &N = UnusedArgNodeMap[V];
603603 assert(N.getNode() == 0 && "Already set a value for this node!");
672672 void visitJumpTable(JumpTable &JT);
673673 void visitJumpTableHeader(JumpTable &JT, JumpTableHeader &JTH,
674674 MachineBasicBlock *SwitchBB);
675
675
676676 private:
677677 // These all get lowered before this pass.
678678 void visitInvoke(const InvokeInst &I);
765765 void HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB);
766766
767767 /// EmitFuncArgumentDbgValue - If V is an function argument then create
768 /// corresponding DBG_VALUE machine instruction for it now. At the end of
768 /// corresponding DBG_VALUE machine instruction for it now. At the end of
769769 /// instruction selection, they will be inserted to the entry BB.
770770 bool EmitFuncArgumentDbgValue(const Value *V, MDNode *Variable,
771771 int64_t Offset, const SDValue &N);
332332 const MachineOperand &IndexReg = MI->getOperand(Op+2);
333333 const MachineOperand &DispSpec = MI->getOperand(Op+3);
334334 const MachineOperand &SegReg = MI->getOperand(Op+4);
335
335
336336 // If this has a segment register, print it.
337337 if (SegReg.getReg()) {
338338 printOperand(MI, Op+4, O, Modifier, AsmVariant);
339339 O << ':';
340340 }
341
341
342342 O << '[';
343
343
344344 bool NeedPlus = false;
345345 if (BaseReg.getReg()) {
346346 printOperand(MI, Op, O, Modifier, AsmVariant);
347347 NeedPlus = true;
348348 }
349
349
350350 if (IndexReg.getReg()) {
351351 if (NeedPlus) O << " + ";
352352 if (ScaleVal != 1)
278278 // The first 4 integer arguments are passed in integer registers.
279279 CCIfType<[i32], CCAssignToRegWithShadow<[ECX , EDX , R8D , R9D ],
280280 [XMM0, XMM1, XMM2, XMM3]>>,
281
281
282282 // Do not pass the sret argument in RCX, the Win64 thiscall calling
283 // convention requires "this" to be passed in RCX.
284 CCIfCC<"CallingConv::X86_ThisCall",
283 // convention requires "this" to be passed in RCX.
284 CCIfCC<"CallingConv::X86_ThisCall",
285285 CCIfSRet
286286 [XMM1, XMM2, XMM3]>>>>,
287287
353353 // Integer/Float values get stored in stack slots that are 4 bytes in
354354 // size and 4-byte aligned.
355355 CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
356
356
357357 // Doubles get 8-byte slots that are 4-byte aligned.
358358 CCIfType<[f64], CCAssignToStack<8, 4>>,
359359
557557
558558 // Standard C + YMM6-15
559559 def CSR_Win64_Intel_OCL_BI_AVX : CalleeSavedRegs<(add RBX, RBP, RDI, RSI, R12,
560 R13, R14, R15,
560 R13, R14, R15,
561561 (sequence "YMM%u", 6, 15))>;
562562
563563 def CSR_Win64_Intel_OCL_BI_AVX512 : CalleeSavedRegs<(add RBX, RBP, RDI, RSI,
564 R12, R13, R14, R15,
564 R12, R13, R14, R15,
565565 (sequence "ZMM%u", 6, 21),
566566 K4, K5, K6, K7)>;
567567 //Standard C + XMM 8-15
8383
8484 // Emit the function name recognizer.
8585 EmitFnNameRecognizer(Ints, OS);
86
86
8787 // Emit the intrinsic declaration generator.
8888 EmitGenerator(Ints, OS);
89
89
9090 // Emit the intrinsic parameter attributes.
9191 EmitAttributes(Ints, OS);
9292
124124 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
125125 OS << " " << Ints[i].EnumName;
126126 OS << ((i != e-1) ? ", " : " ");
127 OS << std::string(40-Ints[i].EnumName.size(), ' ')
127 OS << std::string(40-Ints[i].EnumName.size(), ' ')
128128 << "// " << Ints[i].Name << "\n";
129129 }
130130 OS << "#endif\n\n";
145145 };
146146
147147 void IntrinsicEmitter::
148 EmitFnNameRecognizer(const std::vector &Ints,
148 EmitFnNameRecognizer(const std::vector &Ints,
149149 raw_ostream &OS) {
150150 // Build a 'first character of function name' -> intrinsic # mapping.
151151 std::map > IntMapping;
152152 for (unsigned i = 0, e = Ints.size(); i != e; ++i)
153153 IntMapping[Ints[i].Name[5]].push_back(i);
154
154
155155 OS << "// Function name -> enum value recognizer code.\n";
156156 OS << "#ifdef GET_FUNCTION_RECOGNIZER\n";
157157 OS << " StringRef NameR(Name+6, Len-6); // Skip over 'llvm.'\n";
170170 // Emit all the overloaded intrinsics first, build a table of the
171171 // non-overloaded ones.
172172 std::vector MatchTable;
173
173
174174 for (unsigned i = 0, e = IntList.size(); i != e; ++i) {
175175 unsigned IntNo = IntList[i];
176176 std::string Result = "return " + TargetPrefix + "Intrinsic::" +
187187 OS << " if (NameR.startswith(\"" << TheStr << "\")) "
188188 << Result << '\n';
189189 }
190
190
191191 // Emit the matcher logic for the fixed length strings.
192192 StringMatcher("NameR", MatchTable, OS).Emit(1);
193193 OS << " break; // end of '" << I->first << "' case.\n";
194194 }
195
195
196196 OS << " }\n";
197197 OS << "#endif\n\n";
198198 }
199199
200200 void IntrinsicEmitter::
201 EmitIntrinsicToNameTable(const std::vector &Ints,
201 EmitIntrinsicToNameTable(const std::vector &Ints,
202202 raw_ostream &OS) {
203203 OS << "// Intrinsic ID to name table\n";
204204 OS << "#ifdef GET_INTRINSIC_NAME_TABLE\n";
209209 }
210210
211211 void IntrinsicEmitter::
212 EmitIntrinsicToOverloadTable(const std::vector &Ints,
212 EmitIntrinsicToOverloadTable(const std::vector &Ints,
213213 raw_ostream &OS) {
214214 OS << "// Intrinsic ID to overload bitset\n";
215215 OS << "#ifdef GET_INTRINSIC_OVERLOAD_TABLE\n";
277277 case 64: return Sig.push_back(IIT_I64);
278278 }
279279 }
280
280
281281 switch (VT) {
282282 default: PrintFatalError("unhandled MVT in intrinsic!");
283283 case MVT::f16: return Sig.push_back(IIT_F16);
292292
293293 #ifdef _MSC_VER
294294 #pragma optimize("",off) // MSVC 2010 optimizer can't deal with this function.
295 #endif
295 #endif
296296
297297 static void EncodeFixedType(Record *R, std::vector &ArgCodes,
298298 std::vector &Sig) {
299
299
300300 if (R->isSubClassOf("LLVMMatchType")) {
301301 unsigned Number = R->getValueAsInt("Number");
302302 assert(Number < ArgCodes.size() && "Invalid matching number!");
308308 Sig.push_back(IIT_ARG);
309309 return Sig.push_back((Number << 2) | ArgCodes[Number]);
310310 }
311
311
312312 MVT::SimpleValueType VT = getValueType(R->getValueAsDef("VT"));
313313
314314 unsigned Tmp = 0;
319319 case MVT::fAny: ++Tmp; // FALL THROUGH.
320320 case MVT::iAny: {
321321 // If this is an "any" valuetype, then the type is the type of the next
322 // type in the list specified to getIntrinsic().
322 // type in the list specified to getIntrinsic().
323323 Sig.push_back(IIT_ARG);
324
324
325325 // Figure out what arg # this is consuming, and remember what kind it was.
326326 unsigned ArgNo = ArgCodes.size();
327327 ArgCodes.push_back(Tmp);
328
328
329329 // Encode what sort of argument it must be in the low 2 bits of the ArgNo.
330330 return Sig.push_back((ArgNo << 2) | Tmp);
331331 }
332
332
333333 case MVT::iPTR: {
334334 unsigned AddrSpace = 0;
335335 if (R->isSubClassOf("LLVMQualPointerType")) {
345345 return EncodeFixedType(R->getValueAsDef("ElTy"), ArgCodes, Sig);
346346 }
347347 }
348
348
349349 if (EVT(VT).isVector()) {
350350 EVT VVT = VT;
351351 switch (VVT.getVectorNumElements()) {
357357 case 16: Sig.push_back(IIT_V16); break;
358358 case 32: Sig.push_back(IIT_V32); break;
359359 }
360
360
361361 return EncodeFixedValueType(VVT.getVectorElementType().
362362 getSimpleVT().SimpleTy, Sig);
363363 }
374374 static void ComputeFixedEncoding(const CodeGenIntrinsic &Int,
375375 std::vector &TypeSig) {
376376 std::vector ArgCodes;
377
377
378378 if (Int.IS.RetVTs.empty())
379379 TypeSig.push_back(IIT_Done);
380380 else if (Int.IS.RetVTs.size() == 1 &&
389389 case 5: TypeSig.push_back(IIT_STRUCT5); break;
390390 default: assert(0 && "Unhandled case in struct");
391391 }
392
392
393393 for (unsigned i = 0, e = Int.IS.RetVTs.size(); i != e; ++i)
394394 EncodeFixedType(Int.IS.RetTypeDefs[i], ArgCodes, TypeSig);
395395 }
396
396
397397 for (unsigned i = 0, e = Int.IS.ParamTypeDefs.size(); i != e; ++i)
398398 EncodeFixedType(Int.IS.ParamTypeDefs[i], ArgCodes, TypeSig);
399399 }
402402 OS << (unsigned)X;
403403 }
404404
405 void IntrinsicEmitter::EmitGenerator(const std::vector &Ints,
405 void IntrinsicEmitter::EmitGenerator(const std::vector &Ints,
406406 raw_ostream &OS) {
407407 // If we can compute a 32-bit fixed encoding for this intrinsic, do so and
408408 // capture it in this vector, otherwise store a ~0U.
409409 std::vector FixedEncodings;
410
410
411411 SequenceToOffsetTable > LongEncodingTable;
412
412
413413 std::vector TypeSig;
414
414
415415 // Compute the unique argument type info.
416416 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
417417 // Get the signature for the intrinsic.
431431 }
432432 Result = (Result << 4) | TypeSig[e-i-1];
433433 }
434
434
435435 // If this could be encoded into a 31-bit word, return it.
436436 if (!Failed && (Result >> 31) == 0) {
437437 FixedEncodings.push_back(Result);
442442 // Otherwise, we're going to unique the sequence into the
443443 // LongEncodingTable, and use its offset in the 32-bit table instead.
444444 LongEncodingTable.add(TypeSig);
445
445
446446 // This is a placehold that we'll replace after the table is laid out.
447447 FixedEncodings.push_back(~0U);
448448 }
449
449
450450 LongEncodingTable.layout();
451
451
452452 OS << "// Global intrinsic function declaration type table.\n";
453453 OS << "#ifdef GET_INTRINSIC_GENERATOR_GLOBAL\n";
454454
455455 OS << "static const unsigned IIT_Table[] = {\n ";
456
456
457457 for (unsigned i = 0, e = FixedEncodings.size(); i != e; ++i) {
458458 if ((i & 7) == 7)
459459 OS << "\n ";
460
460
461461 // If the entry fit in the table, just emit it.
462462 if (FixedEncodings[i] != ~0U) {
463463 OS << "0x" << utohexstr(FixedEncodings[i]) << ", ";
464464 continue;
465465 }
466
466
467467 TypeSig.clear();
468468 ComputeFixedEncoding(Ints[i], TypeSig);
469469
470
470
471471 // Otherwise, emit the offset into the long encoding table. We emit it this
472472 // way so that it is easier to read the offset in the .def file.
473473 OS << "(1U<<31) | " << LongEncodingTable.get(TypeSig) << ", ";
474474 }
475
475
476476 OS << "0\n};\n\n";
477
477
478478 // Emit the shared table of register lists.
479479 OS << "static const unsigned char IIT_LongEncodingTable[] = {\n";
480480 if (!LongEncodingTable.empty())
481481 LongEncodingTable.emit(OS, printIITEntry);
482482 OS << " 255\n};\n\n";
483
483
484484 OS << "#endif\n\n"; // End of GET_INTRINSIC_GENERATOR_GLOBAL
485485 }
486486
630630 OS << " AttrVec.push_back(Attribute::ReadOnly);\n";
631631 break;
632632 case MRK_readnone:
633 OS << " AttrVec.push_back(Attribute::ReadNone);\n";
633 OS << " AttrVec.push_back(Attribute::ReadNone);\n";
634634 break;
635635 }
636636 OS << " AS[" << numAttrs++ << "] = AttributeSet::get(C, "
644644 OS << " return AttributeSet();\n";
645645 }
646646 }
647
647
648648 OS << " }\n";
649649 OS << " }\n";
650650 OS << " return AttributeSet::get(C, ArrayRef(AS, "
693693 static void EmitTargetBuiltins(const std::map &BIM,
694694 const std::string &TargetPrefix,
695695 raw_ostream &OS) {
696
696
697697 std::vector Results;
698
698
699699 for (std::map::const_iterator I = BIM.begin(),
700700 E = BIM.end(); I != E; ++I) {
701701 std::string ResultCode =
706706 StringMatcher("BuiltinName", Results, OS).Emit();
707707 }
708708
709
709
710710 void IntrinsicEmitter::
711 EmitIntrinsicToGCCBuiltinMap(const std::vector &Ints,
711 EmitIntrinsicToGCCBuiltinMap(const std::vector &Ints,
712712 raw_ostream &OS) {
713713 typedef std::map > BIMTy;
714714 BIMTy BuiltinMap;
716716 if (!Ints[i].GCCBuiltinName.empty()) {
717717 // Get the map for this target prefix.
718718 std::map &BIM =BuiltinMap[Ints[i].TargetPrefix];
719
719
720720 if (!BIM.insert(std::make_pair(Ints[i].GCCBuiltinName,
721721 Ints[i].EnumName)).second)
722722 PrintFatalError("Intrinsic '" + Ints[i].TheDef->getName() +
723723 "': duplicate GCC builtin name!");
724724 }
725725 }
726
726
727727 OS << "// Get the LLVM intrinsic that corresponds to a GCC builtin.\n";
728728 OS << "// This is used by the C front-end. The GCC builtin name is passed\n";
729729 OS << "// in as BuiltinName, and a target prefix (e.g. 'ppc') is passed\n";
730730 OS << "// in as TargetPrefix. The result is assigned to 'IntrinsicID'.\n";
731731 OS << "#ifdef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN\n";
732
732
733733 if (TargetOnly) {
734734 OS << "static " << TargetPrefix << "Intrinsic::ID "
735735 << "getIntrinsicForGCCBuiltin(const char "
738738 OS << "Intrinsic::ID Intrinsic::getIntrinsicForGCCBuiltin(const char "
739739 << "*TargetPrefixStr, const char *BuiltinNameStr) {\n";
740740 }
741
741
742742 OS << " StringRef BuiltinName(BuiltinNameStr);\n";
743743 OS << " StringRef TargetPrefix(TargetPrefixStr);\n\n";
744
744
745745 // Note: this could emit significantly better code if we cared.
746746 for (BIMTy::iterator I = BuiltinMap.begin(), E = BuiltinMap.end();I != E;++I){
747747 OS << " ";