================ @@ -3532,6 +3533,72 @@ void CXXNameMangler::mangleExtFunctionInfo(const FunctionType *T) { // FIXME: noreturn } +enum class AAPCSBitmaskSME : unsigned { + ArmStreamingBit = 1 << 0, + ArmStreamingCompatibleBit = 1 << 1, + ArmAgnosticSMEZAStateBit = 1 << 2, + ZA_Shift = 3, + ZT0_Shift = 6, + NoState = 0b000, + ArmIn = 0b001, + ArmOut = 0b010, + ArmInOut = 0b011, + ArmPreserves = 0b100, + LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/ArmPreserves) +}; + +static AAPCSBitmaskSME encodeAAPCSZAState(unsigned SMEAttrs) { + switch (SMEAttrs) { + case FunctionType::ARM_None: + return AAPCSBitmaskSME::NoState; + case FunctionType::ARM_In: + return AAPCSBitmaskSME::ArmIn; + case FunctionType::ARM_Out: + return AAPCSBitmaskSME::ArmOut; + case FunctionType::ARM_InOut: + return AAPCSBitmaskSME::ArmInOut; + case FunctionType::ARM_Preserves: + return AAPCSBitmaskSME::ArmPreserves; + default: + llvm_unreachable("Unrecognised SME attribute"); + } +} + +// The mangling scheme for function types which have SME attributes is +// implemented as a "pseudo" template: +// +// '__SME_ATTRS<<normal_function_type>, <sme_state>>' +// +// Combining the function type with a bitmask representing the streaming and ZA +// properties of the function's interface. +// +// Mangling of SME keywords is described in more detail in the AArch64 ACLE: +// https://github.com/ARM-software/acle/blob/main/main/acle.md#c-mangling-of-sme-keywords +// +void CXXNameMangler::mangleSMEAttrs(unsigned SMEAttrs) { + if (!SMEAttrs) + return; + + unsigned Bitmask = 0; + if (SMEAttrs & FunctionType::SME_PStateSMEnabledMask) + Bitmask |= static_cast<unsigned>(AAPCSBitmaskSME::ArmStreamingBit); ---------------- sdesmalen-arm wrote:
You can remove the `static_cast` if you change `Bitmask` to `AAPCSBitmaskSME`. Then the only place that still requires a bitcast is where you print `Bitmask` to `Out`. https://github.com/llvm/llvm-project/pull/114209 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits