Skip to content

Commit 1546397

Browse files
authored
Merge pull request llvm#317 from AMD-Lightning-Internal/upstream_merge_202501270800
merge main into amd-staging
2 parents 15e7523 + 5fe9d07 commit 1546397

File tree

63 files changed

+6966
-455
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+6966
-455
lines changed

clang/include/clang/AST/Type.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,6 +2518,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
25182518
bool isFloat32Type() const;
25192519
bool isDoubleType() const;
25202520
bool isBFloat16Type() const;
2521+
bool isMFloat8Type() const;
25212522
bool isFloat128Type() const;
25222523
bool isIbm128Type() const;
25232524
bool isRealType() const; // C99 6.2.5p17 (real floating + integer)
@@ -8537,6 +8538,10 @@ inline bool Type::isBFloat16Type() const {
85378538
return isSpecificBuiltinType(BuiltinType::BFloat16);
85388539
}
85398540

8541+
inline bool Type::isMFloat8Type() const {
8542+
return isSpecificBuiltinType(BuiltinType::MFloat8);
8543+
}
8544+
85408545
inline bool Type::isFloat128Type() const {
85418546
return isSpecificBuiltinType(BuiltinType::Float128);
85428547
}

clang/include/clang/Basic/AArch64SVEACLETypes.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4T
201201
SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy)
202202

203203
AARCH64_VECTOR_TYPE_MFLOAT("__mfp8", "__mfp8", MFloat8, MFloat8Ty, 1, 8, 1)
204-
AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x8_t", "__MFloat8x8_t", MFloat8x8, MFloat8x8Ty, 8, 8, 1)
205-
AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x16_t", "__MFloat8x16_t", MFloat8x16, MFloat8x16Ty, 16, 8, 1)
206204

207205
#undef SVE_VECTOR_TYPE
208206
#undef SVE_VECTOR_TYPE_BFLOAT

clang/include/clang/Basic/TargetBuiltins.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ namespace clang {
208208
Float16,
209209
Float32,
210210
Float64,
211-
BFloat16
211+
BFloat16,
212+
MFloat8
212213
};
213214

214215
NeonTypeFlags(unsigned F) : Flags(F) {}
@@ -230,6 +231,7 @@ namespace clang {
230231
switch (getEltType()) {
231232
case Int8:
232233
case Poly8:
234+
case MFloat8:
233235
return 8;
234236
case Int16:
235237
case Float16:

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7122,8 +7122,11 @@ defm unsigned : OptInFC1FFlag<"unsigned", "Enables UNSIGNED type">;
71227122
def fno_automatic : Flag<["-"], "fno-automatic">, Group<f_Group>,
71237123
HelpText<"Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE">;
71247124

7125-
def fsave_main_program : Flag<["-"], "fsave-main-program">, Group<f_Group>,
7126-
HelpText<"Place all variables from the main program in static memory (otherwise scalars may be placed on the stack)">;
7125+
defm save_main_program : BoolOptionWithoutMarshalling<"f", "save-main-program",
7126+
PosFlag<SetTrue, [], [],
7127+
"Place all main program variables in static memory (otherwise scalars may be placed on the stack)">,
7128+
NegFlag<SetFalse, [], [],
7129+
"Allow placing main program variables on the stack (default)">>;
71277130

71287131
defm stack_arrays : BoolOptionWithoutMarshalling<"f", "stack-arrays",
71297132
PosFlag<SetTrue, [], [ClangOption], "Attempt to allocate array temporaries on the stack, no matter their size">,

clang/lib/AST/ExprConstant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,7 @@ APValue &
19611961
CallStackFrame::createConstexprUnknownAPValues(const VarDecl *Key,
19621962
APValue::LValueBase Base) {
19631963
APValue &Result = ConstexprUnknownAPValues[MapKeyTy(Key, Base.getVersion())];
1964-
Result = APValue(Base, CharUnits::One(), APValue::ConstexprUnknown{});
1964+
Result = APValue(Base, CharUnits::Zero(), APValue::ConstexprUnknown{});
19651965

19661966
return Result;
19671967
}

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3919,6 +3919,9 @@ void CXXNameMangler::mangleNeonVectorType(const VectorType *T) {
39193919
case BuiltinType::Float: EltName = "float32_t"; break;
39203920
case BuiltinType::Half: EltName = "float16_t"; break;
39213921
case BuiltinType::BFloat16: EltName = "bfloat16_t"; break;
3922+
case BuiltinType::MFloat8:
3923+
EltName = "mfloat8_t";
3924+
break;
39223925
default:
39233926
llvm_unreachable("unexpected Neon vector element type");
39243927
}
@@ -3972,6 +3975,8 @@ static StringRef mangleAArch64VectorBase(const BuiltinType *EltType) {
39723975
return "Float64";
39733976
case BuiltinType::BFloat16:
39743977
return "Bfloat16";
3978+
case BuiltinType::MFloat8:
3979+
return "Mfloat8";
39753980
default:
39763981
llvm_unreachable("Unexpected vector element base type");
39773982
}

clang/lib/AST/TemplateBase.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -515,19 +515,17 @@ void TemplateArgument::print(const PrintingPolicy &Policy, raw_ostream &Out,
515515
}
516516

517517
case Declaration: {
518-
NamedDecl *ND = getAsDecl();
518+
ValueDecl *VD = getAsDecl();
519519
if (getParamTypeForDecl()->isRecordType()) {
520-
if (auto *TPO = dyn_cast<TemplateParamObjectDecl>(ND)) {
520+
if (auto *TPO = dyn_cast<TemplateParamObjectDecl>(VD)) {
521521
TPO->getType().getUnqualifiedType().print(Out, Policy);
522522
TPO->printAsInit(Out, Policy);
523523
break;
524524
}
525525
}
526-
if (auto *VD = dyn_cast<ValueDecl>(ND)) {
527-
if (needsAmpersandOnTemplateArg(getParamTypeForDecl(), VD->getType()))
528-
Out << "&";
529-
}
530-
ND->printQualifiedName(Out);
526+
if (needsAmpersandOnTemplateArg(getParamTypeForDecl(), VD->getType()))
527+
Out << "&";
528+
VD->printQualifiedName(Out);
531529
break;
532530
}
533531

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,10 +710,36 @@ void TextNodeDumper::Visit(const APValue &Value, QualType Ty) {
710710
<< GetApproxValue(Value.getComplexFloatImag()) << 'i';
711711
}
712712
return;
713-
case APValue::LValue:
713+
case APValue::LValue: {
714714
(void)Context;
715-
OS << "LValue <todo>";
715+
OS << "LValue Base=";
716+
APValue::LValueBase B = Value.getLValueBase();
717+
if (B.isNull())
718+
OS << "null";
719+
else if (const auto *BE = B.dyn_cast<const Expr *>()) {
720+
OS << BE->getStmtClassName() << ' ';
721+
dumpPointer(BE);
722+
} else {
723+
const auto *VDB = B.get<const ValueDecl *>();
724+
OS << VDB->getDeclKindName() << "Decl";
725+
dumpPointer(VDB);
726+
}
727+
OS << ", Null=" << Value.isNullPointer()
728+
<< ", Offset=" << Value.getLValueOffset().getQuantity()
729+
<< ", HasPath=" << Value.hasLValuePath();
730+
if (Value.hasLValuePath()) {
731+
OS << ", PathLength=" << Value.getLValuePath().size();
732+
OS << ", Path=(";
733+
llvm::ListSeparator Sep;
734+
for (const auto &PathEntry : Value.getLValuePath()) {
735+
// We're printing all entries as array indices because don't have the
736+
// type information here to do anything else.
737+
OS << Sep << PathEntry.getAsArrayIndex();
738+
}
739+
OS << ")";
740+
}
716741
return;
742+
}
717743
case APValue::Array: {
718744
unsigned ArraySize = Value.getArraySize();
719745
unsigned NumInitializedElements = Value.getArrayInitializedElts();

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6673,6 +6673,7 @@ static llvm::FixedVectorType *GetNeonType(CodeGenFunction *CGF,
66736673
switch (TypeFlags.getEltType()) {
66746674
case NeonTypeFlags::Int8:
66756675
case NeonTypeFlags::Poly8:
6676+
case NeonTypeFlags::MFloat8:
66766677
return llvm::FixedVectorType::get(CGF->Int8Ty, V1Ty ? 1 : (8 << IsQuad));
66776678
case NeonTypeFlags::Int16:
66786679
case NeonTypeFlags::Poly16:

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,8 +2414,15 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
24142414
Vec = Builder.CreateBitCast(Vec, IRVecTy);
24152415
// iN --> <N x i1>.
24162416
}
2417-
Vec = Builder.CreateInsertElement(Vec, Src.getScalarVal(),
2418-
Dst.getVectorIdx(), "vecins");
2417+
llvm::Value *SrcVal = Src.getScalarVal();
2418+
// Allow inserting `<1 x T>` into an `<N x T>`. It can happen with scalar
2419+
// types which are mapped to vector LLVM IR types (e.g. for implementing
2420+
// an ABI).
2421+
if (auto *EltTy = dyn_cast<llvm::FixedVectorType>(SrcVal->getType());
2422+
EltTy && EltTy->getNumElements() == 1)
2423+
SrcVal = Builder.CreateBitCast(SrcVal, EltTy->getElementType());
2424+
Vec = Builder.CreateInsertElement(Vec, SrcVal, Dst.getVectorIdx(),
2425+
"vecins");
24192426
if (IRStoreTy) {
24202427
// <N x i1> --> <iN>.
24212428
Vec = Builder.CreateBitCast(Vec, IRStoreTy);

0 commit comments

Comments
 (0)