Skip to content

Commit c872a0b

Browse files
committed
Make Injective and HyperView parameter attributes; add tapir_frame intrinsic
1 parent 14f9bbe commit c872a0b

30 files changed

Lines changed: 503 additions & 389 deletions

clang/include/clang/Basic/Attr.td

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4227,21 +4227,14 @@ def StrandMalloc : InheritableAttr {
42274227
}
42284228

42294229
def Injective : InheritableAttr {
4230-
// TODO: Associate this with a single argument, not the function.
42314230
let Spellings = [Clang<"injective">];
4232-
let Subjects = SubjectList<[Function]>;
4231+
let Subjects = SubjectList<[ParmVar]>;
42334232
let Documentation = [Undocumented];
42344233
}
42354234

42364235
def HyperView : InheritableAttr {
42374236
let Spellings = [Clang<"hyper_view">];
4238-
let Subjects = SubjectList<[FunctionLike]>;
4239-
let Documentation = [StrandMallocDocs];
4240-
}
4241-
4242-
def HyperToken : InheritableAttr {
4243-
let Spellings = [Clang<"hyper_token">];
4244-
let Subjects = SubjectList<[FunctionLike]>;
4237+
let Subjects = SubjectList<[ParmVar]>;
42454238
let Documentation = [StrandMallocDocs];
42464239
}
42474240

clang/include/clang/Basic/Builtins.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,6 +1758,8 @@ BUILTIN(__builtin_ms_va_copy, "vc*&c*&", "n")
17581758
// Arithmetic Fence: to prevent FP reordering and reassociation optimizations
17591759
LANGBUILTIN(__arithmetic_fence, "v.", "tE", ALL_LANGUAGES)
17601760

1761+
BUILTIN(__tapir_frame, "v*", "n")
1762+
17611763
// Tapir. Rewriting of reducer references happens during sema
17621764
// and needs a builtin to carry the information to codegen.
17631765
BUILTIN(__hyper_lookup, "v*vC*z.", "nU")

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5536,15 +5536,27 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
55365536
Str.getPointer(), Zeros);
55375537
return RValue::get(Ptr);
55385538
}
5539+
case Builtin::BI__tapir_frame: {
5540+
Function *FF = CGM.getIntrinsic(Intrinsic::tapir_frame);
5541+
return RValue::get(Builder.CreateCall(FF, {}));
5542+
}
55395543
case Builtin::BI__hyper_lookup: {
5544+
Function *TF = CGM.getIntrinsic(Intrinsic::tapir_frame);
5545+
llvm::Value *Frame = Builder.CreateCall(TF, {});
55405546
llvm::Value *Size = EmitScalarExpr(E->getArg(1));
55415547
Function *F = CGM.getIntrinsic(Intrinsic::hyper_lookup, Size->getType());
55425548
llvm::Value *Ptr = EmitScalarExpr(E->getArg(0));
55435549
llvm::Value *Identity = EmitScalarExpr(E->getArg(2));
55445550
llvm::Value *Reduce = EmitScalarExpr(E->getArg(3));
5545-
return RValue::get(Builder.CreateCall(
5546-
F, {Ptr, Size, Builder.CreateBitCast(Identity, VoidPtrTy),
5547-
Builder.CreateBitCast(Reduce, VoidPtrTy)}));
5551+
CallInst *Call =
5552+
Builder.CreateCall(F,
5553+
{Frame, Ptr, Size,
5554+
Builder.CreateBitCast(Identity, VoidPtrTy),
5555+
Builder.CreateBitCast(Reduce, VoidPtrTy)});
5556+
// TODO: These should be added automatically based on the function type.
5557+
Call->addParamAttr(1, Attribute::Injective);
5558+
Call->addParamAttr(1, Attribute::HyperView);
5559+
return RValue::get(Call);
55485560
}
55495561
}
55505562
IsSpawnedScope SpawnedScp(this);

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9510,9 +9510,6 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
95109510
case ParsedAttr::AT_HyperView:
95119511
handleSimpleAttribute<HyperViewAttr>(S, D, AL);
95129512
break;
9513-
case ParsedAttr::AT_HyperToken:
9514-
handleSimpleAttribute<HyperTokenAttr>(S, D, AL);
9515-
break;
95169513
case ParsedAttr::AT_ReducerUnregister:
95179514
handleSimpleAttribute<ReducerUnregisterAttr>(S, D, AL);
95189515
break;

clang/test/Cilk/hyper-array-extern-1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ int read_array_hyper(unsigned i)
1010
{
1111
return x[i];
1212
// CHECK: %[[ARRAYIDX:.+]] = getelementptr inbounds
13-
// CHECK: %[[VIEWRAW:.+]] = call ptr @llvm.hyper.lookup.i64(ptr %[[ARRAYIDX]], i64 4, ptr null, ptr null)
13+
// CHECK: %[[VIEWRAW:.+]] = call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective %[[ARRAYIDX]], i64 4, ptr null, ptr null)
1414
// CHECK-NOT: call ptr @llvm.hyper.lookup
1515
// CHECK: %[[VAL:.+]] = load i32, ptr %[[VIEWRAW]]
1616
// CHECK: ret i32 %[[VAL]]

clang/test/Cilk/hyper-assign.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ extern long _Hyperobject x, _Hyperobject y;
66

77
long chain_assign()
88
{
9-
// CHECK: %[[Y1RAW:.+]] = call ptr @llvm.hyper.lookup.i64(ptr @y, i64 8, ptr null, ptr null)
9+
// CHECK: %[[Y1RAW:.+]] = call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @y, i64 8, ptr null, ptr null)
1010
// CHECK: %[[Y1VAL:.+]] = load i64, ptr %[[Y1RAW]]
11-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr @x, i64 8, ptr null, ptr null)
11+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @x, i64 8, ptr null, ptr null)
1212
// CHECK: store i64 %[[Y1VAL]]
13-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr @y, i64 8, ptr null, ptr null)
14-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr @x, i64 8, ptr null, ptr null)
13+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @y, i64 8, ptr null, ptr null)
14+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @x, i64 8, ptr null, ptr null)
1515
return x = y = x = y;
1616
}
1717

1818
long simple_assign(long val)
1919
{
20-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr @x, i64 8, ptr null, ptr null)
20+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @x, i64 8, ptr null, ptr null)
2121
// CHECK-NOT: call ptr @llvm.hyper.lookup
2222
// CHECK: store i64
2323
return x = val;
@@ -26,11 +26,11 @@ long simple_assign(long val)
2626
long subtract()
2727
{
2828
// The order is not fixed here.
29-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr @y, i64 8, ptr null, ptr null)
29+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @y, i64 8, ptr null, ptr null)
3030
// CHECK: load i64
3131
// CHECK: add nsw i64 %[[Y:.+]], 1
3232
// CHECK: store i64
33-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr @x, i64 8, ptr null, ptr null)
33+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @x, i64 8, ptr null, ptr null)
3434
// CHECK: load i64
3535
// CHECK: sub nsw
3636
// CHECK: store i64

clang/test/Cilk/hyper-complex.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern __complex__ float _Hyperobject c;
77
// CHECK-LABEL: get_real
88
float get_real()
99
{
10-
// CHECK: %[[RAW1:.+]] = call ptr @llvm.hyper.lookup.i64(ptr @c, i64 8, ptr null, ptr null)
10+
// CHECK: %[[RAW1:.+]] = call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @c, i64 8, ptr null, ptr null)
1111
// CHECK: %[[FIELD1:.+]] = getelementptr inbounds { float, float }, ptr %[[RAW1]], i32 0, i32 0
1212
// CHECK: %[[RET1:.+]] = load float, ptr %[[FIELD1]]
1313
// CHECK: ret float %[[RET1]]
@@ -16,7 +16,7 @@ float get_real()
1616
// CHECK-LABEL: get_imag
1717
float get_imag()
1818
{
19-
// CHECK: %[[RAW2:.+]] = call ptr @llvm.hyper.lookup.i64(ptr @c, i64 8, ptr null, ptr null)
19+
// CHECK: %[[RAW2:.+]] = call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @c, i64 8, ptr null, ptr null)
2020
// CHECK: %[[FIELD2:.+]] = getelementptr inbounds { float, float }, ptr %[[RAW2]], i32 0, i32 1
2121
// CHECK: load float, ptr %[[FIELD2]]
2222
// CHECK: ret float
@@ -27,7 +27,7 @@ float get_imag()
2727
float get_abs()
2828
{
2929
// Only one call to llvm.hyper.lookup.
30-
// CHECK: @llvm.hyper.lookup.i64(ptr @c, i64 8, ptr null, ptr null)
30+
// CHECK: @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @c, i64 8, ptr null, ptr null)
3131
// CHECK-NOT: @llvm.hyper.lookup
3232
// CHECK: call float @cabsf
3333
// CHECK: ret float

clang/test/Cilk/hyper-copy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ extern struct S b __attribute__((aligned(8)));
99
// CHECK-LABEL: scopy
1010
void scopy()
1111
{
12-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr @a, i64 8, ptr null, ptr null)
12+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @a, i64 8, ptr null, ptr null)
1313
// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 @b,
14-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr @a, i64 8, ptr null, ptr null)
14+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @a, i64 8, ptr null, ptr null)
1515
// CHECK: call void @llvm.memcpy.p0.p0.i64
1616
// CHECK: ret void
1717
b = a;

clang/test/Cilk/hyper-template.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ template<typename T> struct S { T member; };
55
S<long> _Hyperobject S_long;
66

77
// CHECK-LABEL: @_Z1fv
8-
// CHECK: %0 = call ptr @llvm.hyper.lookup.i64(ptr @S_long, i64 8, ptr null, ptr null)
8+
// CHECK: %0 = call ptr @llvm.tapir.frame()
9+
// CHECK: %1 = call ptr @llvm.hyper.lookup.i64(ptr %0, ptr hyper_view injective @S_long, i64 8, ptr null, ptr null)
910
// CHECK-NOT: call ptr @llvm.hyper.lookup
1011
// CHECK: getelementptr
1112
// CHECK: %[[RET:.+]] = load i64

clang/test/Cilk/hyper-unary.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ void function1()
1111
{
1212
// CHECK: store i32 1, ptr %[[Y:.+]],
1313
int _Hyperobject y = 1;
14-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr @x, i64 4, ptr null, ptr null)
14+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @x, i64 4, ptr null, ptr null)
1515
// CHECK: load i32
16-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %[[Y]], i64 4, ptr null, ptr null)
16+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective %[[Y]], i64 4, ptr null, ptr null)
1717
// CHECK: load i32
1818
(void)x; (void)y;
1919
}
@@ -23,9 +23,9 @@ void function2()
2323
{
2424
// CHECK: store i32 1, ptr %[[Y:.+]],
2525
int _Hyperobject y = 1;
26-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr @x, i64 4, ptr null, ptr null)
26+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @x, i64 4, ptr null, ptr null)
2727
// CHECK: load i32
28-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %[[Y]], i64 4, ptr null, ptr null)
28+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective %[[Y]], i64 4, ptr null, ptr null)
2929
// CHECK: load i32
3030
(void)!x; (void)!y;
3131
}
@@ -35,18 +35,18 @@ void function3()
3535
{
3636
// CHECK: store i32 1, ptr %[[Y:.+]],
3737
int _Hyperobject y = 1;
38-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr @x, i64 4, ptr null, ptr null)
38+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @x, i64 4, ptr null, ptr null)
3939
// CHECK: load i32
40-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %[[Y]], i64 4, ptr null, ptr null)
40+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective %[[Y]], i64 4, ptr null, ptr null)
4141
// CHECK: load i32
4242
(void)-x; (void)-y;
43-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr @x, i64 4, ptr null, ptr null)
43+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective @x, i64 4, ptr null, ptr null)
4444
// CHECK: load i32
45-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %[[Y]], i64 4, ptr null, ptr null)
45+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective %[[Y]], i64 4, ptr null, ptr null)
4646
// CHECK: load i32
4747
(void)~x; (void)~y;
4848
// CHECK: %[[XP:.+]] = load ptr, ptr @xp
49-
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %[[XP]], i64 4, ptr null, ptr null)
49+
// CHECK: call ptr @llvm.hyper.lookup.i64(ptr %{{[0-9]+}}, ptr hyper_view injective %[[XP]], i64 4, ptr null, ptr null)
5050
// CHECK: load i32
5151
(void)*xp;
5252
}

0 commit comments

Comments
 (0)