Skip to content

Commit 24142fc

Browse files
Merge branch 'main' into spv_intel_arbitrary_floating_points
2 parents c13a06e + 47d71b6 commit 24142fc

File tree

34 files changed

+570
-102
lines changed

34 files changed

+570
-102
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6007,6 +6007,8 @@ bool Compiler<Emitter>::visitSwitchStmt(const SwitchStmt *S) {
60076007
CaseLabels[SC] = this->getLabel();
60086008

60096009
const Expr *Value = CS->getLHS();
6010+
if (Value->isValueDependent())
6011+
return false;
60106012
PrimType ValueT = this->classifyPrim(Value->getType());
60116013

60126014
// Compare the case statement's value to the switch condition.

clang/lib/AST/ExprConstant.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5452,10 +5452,13 @@ static EvalStmtResult EvaluateSwitch(StmtResult &Result, EvalInfo &Info,
54525452
}
54535453

54545454
const CaseStmt *CS = cast<CaseStmt>(SC);
5455-
APSInt LHS = CS->getLHS()->EvaluateKnownConstInt(Info.Ctx);
5456-
APSInt RHS = CS->getRHS() ? CS->getRHS()->EvaluateKnownConstInt(Info.Ctx)
5457-
: LHS;
5458-
if (LHS <= Value && Value <= RHS) {
5455+
const Expr *LHS = CS->getLHS();
5456+
const Expr *RHS = CS->getRHS();
5457+
if (LHS->isValueDependent() || (RHS && RHS->isValueDependent()))
5458+
return ESR_Failed;
5459+
APSInt LHSValue = LHS->EvaluateKnownConstInt(Info.Ctx);
5460+
APSInt RHSValue = RHS ? RHS->EvaluateKnownConstInt(Info.Ctx) : LHSValue;
5461+
if (LHSValue <= Value && Value <= RHSValue) {
54595462
Found = SC;
54605463
break;
54615464
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %clang_cc1 -std=c++20 %s -verify
2+
// RUN: %clang_cc1 -std=c++20 %s -verify -fexperimental-new-constant-interpreter
3+
4+
constexpr bool e(int){switch(0)0=0:return t(;} // expected-error {{expression is not assignable}} \
5+
// expected-error {{expected 'case' keyword before expression}} \
6+
// expected-error {{expected expression}}

libc/startup/baremetal/arm/start.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,32 @@ namespace LIBC_NAMESPACE_DECL {
131131
__arm_wsr("CPSR_c", 0x13); // SVC
132132
#endif
133133

134+
#ifdef __ARM_FP
135+
// Enable FPU
136+
#if __ARM_ARCH_PROFILE == 'M'
137+
// Based on
138+
// https://developer.arm.com/documentation/dui0646/c/Cortex-M7-Peripherals/Floating-Point-Unit/Enabling-the-FPU
139+
// Set CPACR cp10 and cp11
140+
auto cpacr = (volatile uint32_t *const)0xE000ED88;
141+
*cpacr |= (0xF << 20);
142+
__dsb(0xF);
143+
__isb(0xF);
144+
#elif __ARM_ARCH_PROFILE == 'A' || __ARM_ARCH_PROFILE == 'R'
145+
// Based on
146+
// https://developer.arm.com/documentation/dui0472/m/Compiler-Coding-Practices/Enabling-NEON-and-FPU-for-bare-metal
147+
// Set CPACR cp10 and cp11
148+
uint32_t cpacr = __arm_rsr("p15:0:c1:c0:2");
149+
cpacr |= (0xF << 20);
150+
__arm_wsr("p15:0:c1:c0:2", cpacr);
151+
__isb(0xF);
152+
// Set FPEXC.EN
153+
uint32_t fpexc;
154+
__asm__ __volatile__("vmrs %0, FPEXC" : "=r"(fpexc) : :);
155+
fpexc |= (1 << 30);
156+
__asm__ __volatile__("vmsr FPEXC, %0" : : "r"(fpexc) :);
157+
#endif
158+
#endif
159+
134160
// Perform the equivalent of scatterloading
135161
LIBC_NAMESPACE::memcpy(__data_start, __data_source,
136162
reinterpret_cast<uintptr_t>(__data_size));

llvm/docs/SPIRVUsage.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ Below is a list of supported SPIR-V extensions, sorted alphabetically by their e
241241
- Adds predicated load and store instructions that conditionally read from or write to memory based on a boolean predicate.
242242
* - ``SPV_KHR_maximal_reconvergence``
243243
- Adds execution mode and capability to enable maximal reconvergence.
244+
* - ``SPV_ALTERA_blocking_pipes``
245+
- Adds new pipe read and write functions that have blocking semantics instead of the non-blocking semantics of the existing pipe read/write functions.
244246

245247
SPIR-V representation in LLVM IR
246248
================================

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,8 +1331,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
13311331
bool SplitDst =
13321332
TLI->getTypeAction(Dst->getContext(), TLI->getValueType(DL, Dst)) ==
13331333
TargetLowering::TypeSplitVector;
1334-
if ((SplitSrc || SplitDst) && SrcVTy->getElementCount().isVector() &&
1335-
DstVTy->getElementCount().isVector()) {
1334+
if ((SplitSrc || SplitDst) && SrcVTy->getElementCount().isKnownEven() &&
1335+
DstVTy->getElementCount().isKnownEven()) {
13361336
Type *SplitDstTy = VectorType::getHalfElementsVectorType(DstVTy);
13371337
Type *SplitSrcTy = VectorType::getHalfElementsVectorType(SrcVTy);
13381338
const T *TTI = thisT();

llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,6 +2390,15 @@ static bool generateBindlessImageINTELInst(const SPIRV::IncomingCall *Call,
23902390
return buildBindlessImageINTELInst(Call, Opcode, MIRBuilder, GR);
23912391
}
23922392

2393+
static bool generateBlockingPipesInst(const SPIRV::IncomingCall *Call,
2394+
MachineIRBuilder &MIRBuilder,
2395+
SPIRVGlobalRegistry *GR) {
2396+
const SPIRV::DemangledBuiltin *Builtin = Call->Builtin;
2397+
unsigned Opcode =
2398+
SPIRV::lookupNativeBuiltin(Builtin->Name, Builtin->Set)->Opcode;
2399+
return buildOpFromWrapper(MIRBuilder, Opcode, Call, Register(0));
2400+
}
2401+
23932402
static bool
23942403
generateTernaryBitwiseFunctionINTELInst(const SPIRV::IncomingCall *Call,
23952404
MachineIRBuilder &MIRBuilder,
@@ -3095,6 +3104,8 @@ std::optional<bool> lowerBuiltin(const StringRef DemangledCall,
30953104
return generatePipeInst(Call.get(), MIRBuilder, GR);
30963105
case SPIRV::PredicatedLoadStore:
30973106
return generatePredicatedLoadStoreInst(Call.get(), MIRBuilder, GR);
3107+
case SPIRV::BlockingPipes:
3108+
return generateBlockingPipesInst(Call.get(), MIRBuilder, GR);
30983109
}
30993110
return false;
31003111
}

llvm/lib/Target/SPIRV/SPIRVBuiltins.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def Block2DLoadStore : BuiltinGroup;
7272
def ArbitraryFloatingPoint: BuiltinGroup;
7373
def Pipe : BuiltinGroup;
7474
def PredicatedLoadStore : BuiltinGroup;
75+
def BlockingPipes : BuiltinGroup;
7576

7677
//===----------------------------------------------------------------------===//
7778
// Class defining a demangled builtin record. The information in the record
@@ -1218,6 +1219,10 @@ defm : DemangledNativeBuiltin<"clock_read_sub_group", OpenCL_std, KernelClock, 0
12181219
defm : DemangledNativeBuiltin<"clock_read_hilo_device", OpenCL_std, KernelClock, 0, 0, OpReadClockKHR>;
12191220
defm : DemangledNativeBuiltin<"clock_read_hilo_work_group", OpenCL_std, KernelClock, 0, 0, OpReadClockKHR>;
12201221
defm : DemangledNativeBuiltin<"clock_read_hilo_sub_group", OpenCL_std, KernelClock, 0, 0, OpReadClockKHR>;
1222+
1223+
//SPV_ALTERA_blocking_pipes
1224+
defm : DemangledNativeBuiltin<"__spirv_WritePipeBlockingINTEL", OpenCL_std, BlockingPipes, 0, 0, OpWritePipeBlockingALTERA>;
1225+
defm : DemangledNativeBuiltin<"__spirv_ReadPipeBlockingINTEL", OpenCL_std, BlockingPipes, 0, 0, OpReadPipeBlockingALTERA>;
12211226
defm : DemangledNativeBuiltin<"__spirv_ReadClockKHR", OpenCL_std, KernelClock, 1, 1, OpReadClockKHR>;
12221227

12231228
//===----------------------------------------------------------------------===//

llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ static const std::map<std::string, SPIRV::Extension::Extension, std::less<>>
162162
{"SPV_KHR_maximal_reconvergence",
163163
SPIRV::Extension::Extension::SPV_KHR_maximal_reconvergence},
164164
{"SPV_INTEL_kernel_attributes",
165-
SPIRV::Extension::Extension::SPV_INTEL_kernel_attributes}};
165+
SPIRV::Extension::Extension::SPV_INTEL_kernel_attributes},
166+
{"SPV_ALTERA_blocking_pipes",
167+
SPIRV::Extension::Extension::SPV_ALTERA_blocking_pipes}};
166168

167169
bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
168170
StringRef ArgValue,

llvm/lib/Target/SPIRV/SPIRVInstrInfo.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,3 +1096,9 @@ def OpPredicatedLoadINTEL: Op<6528, (outs ID:$res), (ins TYPE:$resType, ID:$ptr,
10961096
"$res = OpPredicatedLoadINTEL $resType $ptr $predicate $default_value">;
10971097
def OpPredicatedStoreINTEL: Op<6529, (outs), (ins ID:$ptr, ID:$object, ID:$predicate, variable_ops),
10981098
"OpPredicatedStoreINTEL $ptr $object $predicate">;
1099+
1100+
//SPV_ALTERA_blocking_pipes
1101+
def OpReadPipeBlockingALTERA :Op<5946, (outs), (ins ID:$pipe, ID:$pointer, ID:$packetSize, ID:$packetAlignment),
1102+
"OpReadPipeBlockingALTERA $pipe $pointer $packetSize $packetAlignment">;
1103+
def OpWritePipeBlockingALTERA :Op<5946, (outs), (ins ID:$pipe, ID:$pointer, ID:$packetSize, ID:$packetAlignment),
1104+
"OpWritePipeBlockingALTERA $pipe $pointer $packetSize $packetAlignment">;

0 commit comments

Comments
 (0)