1 // RUN: llvm-tblgen -gen-intrinsic-impl -I %p/../../include %s | FileCheck %s
3 // Get the minimum blurb necessary to process ...
4 include "llvm/CodeGen/ValueTypes.td"
5 include "llvm/CodeGen/SDNodeProperties.td"
7 class LLVMType<ValueType vt> {
12 def llvm_i32_ty : LLVMType<i32>;
13 def llvm_ptr_ty : LLVMType<iPTR>;
15 class AttrIndex<int idx> {
19 def FuncIndex : AttrIndex<-1>;
20 def RetIndex : AttrIndex<0>;
21 class ArgIndex<int argNo> : AttrIndex<!add(argNo, 1)>;
23 class IntrinsicProperty<bit is_default = 0> {
24 bit IsDefault = is_default;
27 def IntrNoMem : IntrinsicProperty;
28 def IntrHasSideEffects : IntrinsicProperty;
29 class Dereferenceable<AttrIndex idx, int bytes> : IntrinsicProperty {
30 int ArgNo = idx.Value;
34 class Intrinsic<list<LLVMType> ret_types,
35 list<LLVMType> param_types = [],
36 list<IntrinsicProperty> intr_properties = [],
38 list<SDNodeProperty> sd_properties = [],
39 bit disable_default_attributes = 0> : SDPatternOperator {
40 string LLVMName = name;
41 string TargetPrefix = "";
42 list<LLVMType> RetTypes = ret_types;
43 list<LLVMType> ParamTypes = param_types;
44 list<IntrinsicProperty> IntrProperties = intr_properties;
45 let Properties = sd_properties;
46 bit DisableDefaultAttributes = 1;
50 bit DisableDefaultAttributes = disable_default_attributes;
53 // ... this intrinsic.
54 def int_random_gen : Intrinsic<[llvm_i32_ty], [], [IntrNoMem, IntrHasSideEffects]>;
56 def int_deref_ptr_ret : Intrinsic<[llvm_ptr_ty], [], [Dereferenceable<RetIndex, 16>]>;
58 // CHECK: static AttributeSet getIntrinsicArgAttributeSet(LLVMContext &C, unsigned ID) {
59 // CHECK-NEXT: switch (ID) {
60 // CHECK-NEXT: default: llvm_unreachable("Invalid attribute set number");
61 // CHECK-NEXT: case 0:
62 // CHECK-NEXT: return AttributeSet::get(C, {
63 // CHECK-NEXT: Attribute::get(C, Attribute::Dereferenceable, 16),
68 // CHECK: static AttributeSet getIntrinsicFnAttributeSet(
70 // CHECK-NEXT: return AttributeSet::get(C, {
71 // CHECK-NEXT: Attribute::get(C, Attribute::NoUnwind),
75 // CHECK: 1, // llvm.deref.ptr.ret
76 // CHECK: 2, // llvm.random.gen
79 // CHECK-NEXT: AS[0] = {0, getIntrinsicArgAttributeSet(C, 0)};
80 // CHECK-NEXT: AS[1] = {AttributeList::FunctionIndex, getIntrinsicFnAttributeSet(C, 0)};
81 // CHECK-NEXT: NumAttrs = 2;
84 // CHECK-NEXT: AS[0] = {AttributeList::FunctionIndex, getIntrinsicFnAttributeSet(C, 1)};
85 // CHECK-NEXT: NumAttrs = 1;