Skip to content

Commit b264d84

Browse files
- Changed name of SMEState & changed to enum class
- Renamed encodeZAState -> encodeAAPCSZAState - Removed Normal from SMEState enum - Added a link to the relevant section of the AArch64 ACLE doc
1 parent cada212 commit b264d84

File tree

1 file changed

+29
-33
lines changed

1 file changed

+29
-33
lines changed

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3533,72 +3533,68 @@ void CXXNameMangler::mangleExtFunctionInfo(const FunctionType *T) {
35333533
// FIXME: noreturn
35343534
}
35353535

3536-
enum SMEState {
3537-
Normal = 0,
3538-
SM_Enabled = 1 << 0,
3539-
SM_Compatible = 1 << 1,
3540-
ZA_Agnostic = 1 << 2,
3536+
enum class AAPCSBitmaskSME : unsigned {
3537+
ArmStreamingBit = 1 << 0,
3538+
ArmStreamingCompatibleBit = 1 << 1,
3539+
ArmAgnosticSMEZAStateBit = 1 << 2,
35413540
ZA_Shift = 3,
35423541
ZT0_Shift = 6,
3543-
None = 0b000,
3544-
In = 0b001,
3545-
Out = 0b010,
3546-
InOut = 0b011,
3547-
Preserves = 0b100
3542+
NoState = 0b000,
3543+
ArmIn = 0b001,
3544+
ArmOut = 0b010,
3545+
ArmInOut = 0b011,
3546+
ArmPreserves = 0b100
35483547
};
35493548

3550-
unsigned encodeZAState(unsigned SMEAttrs) {
3549+
static unsigned encodeAAPCSZAState(unsigned SMEAttrs) {
35513550
switch (SMEAttrs) {
35523551
case FunctionType::ARM_None:
3553-
return SMEState::None;
3552+
return static_cast<unsigned>(AAPCSBitmaskSME::NoState);
35543553
case FunctionType::ARM_In:
3555-
return SMEState::In;
3554+
return static_cast<unsigned>(AAPCSBitmaskSME::ArmIn);
35563555
case FunctionType::ARM_Out:
3557-
return SMEState::Out;
3556+
return static_cast<unsigned>(AAPCSBitmaskSME::ArmOut);
35583557
case FunctionType::ARM_InOut:
3559-
return SMEState::InOut;
3558+
return static_cast<unsigned>(AAPCSBitmaskSME::ArmInOut);
35603559
case FunctionType::ARM_Preserves:
3561-
return SMEState::Preserves;
3560+
return static_cast<unsigned>(AAPCSBitmaskSME::ArmPreserves);
3561+
default:
3562+
llvm_unreachable("Unrecognised SME attribute");
35623563
}
3563-
llvm_unreachable("Unrecognised SME attribute");
35643564
}
35653565

3566-
// As described in the AArch64 ACLE, the mangling scheme for function types
3567-
// which have SME attributes is implemented as a "pseudo" template:
3566+
// The mangling scheme for function types which have SME attributes is
3567+
// implemented as a "pseudo" template:
35683568
//
35693569
// '__SME_ATTRS<<normal_function_type>, <sme_state>>'
35703570
//
35713571
// Combining the function type with a bitmask representing the streaming and ZA
35723572
// properties of the function's interface.
35733573
//
3574-
// The mangling scheme is otherwise defined in the appendices to the Procedure
3575-
// Call Standard for the Arm Architecture, see
3576-
// https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#appendix-c-mangling
3574+
// Mangling of SME keywords is described in more detail in the AArch64 ACLE:
3575+
// https://github.com/ARM-software/acle/blob/main/main/acle.md#c-mangling-of-sme-keywords
35773576
//
35783577
void CXXNameMangler::mangleSMEAttrs(unsigned SMEAttrs) {
35793578
if (!SMEAttrs)
35803579
return;
35813580

35823581
// Streaming Mode
3583-
unsigned Bitmask = SMEState::Normal;
3582+
unsigned Bitmask = 0;
35843583
if (SMEAttrs & FunctionType::SME_PStateSMEnabledMask)
3585-
Bitmask |= SMEState::SM_Enabled;
3584+
Bitmask |= static_cast<unsigned>(AAPCSBitmaskSME::ArmStreamingBit);
35863585
else if (SMEAttrs & FunctionType::SME_PStateSMCompatibleMask)
3587-
Bitmask |= SMEState::SM_Compatible;
3586+
Bitmask |=
3587+
static_cast<unsigned>(AAPCSBitmaskSME::ArmStreamingCompatibleBit);
35883588

35893589
// TODO: Must represent __arm_agnostic("sme_za_state")
35903590

3591-
// ZA-State
3592-
Bitmask |= encodeZAState(FunctionType::getArmZAState(SMEAttrs))
3593-
<< SMEState::ZA_Shift;
3591+
Bitmask |= encodeAAPCSZAState(FunctionType::getArmZAState(SMEAttrs))
3592+
<< static_cast<unsigned>(AAPCSBitmaskSME::ZA_Shift);
35943593

3595-
// ZT0 State
3596-
Bitmask |= encodeZAState(FunctionType::getArmZT0State(SMEAttrs))
3597-
<< SMEState::ZT0_Shift;
3594+
Bitmask |= encodeAAPCSZAState(FunctionType::getArmZT0State(SMEAttrs))
3595+
<< static_cast<unsigned>(AAPCSBitmaskSME::ZT0_Shift);
35983596

35993597
Out << "Lj" << Bitmask << "EE";
3600-
3601-
return;
36023598
}
36033599

36043600
void

0 commit comments

Comments
 (0)