From 34252802f4e70341b7a3155e449aebbaea29208e Mon Sep 17 00:00:00 2001 From: Stefan Pintilie Date: Tue, 23 Mar 2021 10:31:52 -0500 Subject: [PATCH] [PowerPC] Add mprivileged option Add an option to tell the compiler that it can use privileged instructions. This patch only adds the option. Backend implementation will be added in a future patch. Reviewed By: lei, amyk Differential Revision: https://reviews.llvm.org/D99193 --- lib/Target/PowerPC/PPC.td | 4 ++++ lib/Target/PowerPC/PPCSubtarget.cpp | 1 + lib/Target/PowerPC/PPCSubtarget.h | 2 ++ test/CodeGen/PowerPC/future-check-features.ll | 4 ++-- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Target/PowerPC/PPC.td b/lib/Target/PowerPC/PPC.td index dabfb268293..0503cbcdf62 100644 --- a/lib/Target/PowerPC/PPC.td +++ b/lib/Target/PowerPC/PPC.td @@ -256,6 +256,10 @@ def FeatureROPProtect : SubtargetFeature<"rop-protect", "HasROPProtect", "true", "Add ROP protect">; +def FeaturePrivileged : + SubtargetFeature<"privileged", "HasPrivileged", "true", + "Add privileged instructions">; + def FeaturePredictableSelectIsExpensive : SubtargetFeature<"predictable-select-expensive", "PredictableSelectIsExpensive", diff --git a/lib/Target/PowerPC/PPCSubtarget.cpp b/lib/Target/PowerPC/PPCSubtarget.cpp index 9cd7e9b24d8..9bff07a1de0 100644 --- a/lib/Target/PowerPC/PPCSubtarget.cpp +++ b/lib/Target/PowerPC/PPCSubtarget.cpp @@ -88,6 +88,7 @@ void PPCSubtarget::initializeEnvironment() { HasP9Altivec = false; HasMMA = false; HasROPProtect = false; + HasPrivileged = false; HasP10Vector = false; HasPrefixInstrs = false; HasPCRelativeMemops = false; diff --git a/lib/Target/PowerPC/PPCSubtarget.h b/lib/Target/PowerPC/PPCSubtarget.h index cc18b52ff46..abc7ea1d141 100644 --- a/lib/Target/PowerPC/PPCSubtarget.h +++ b/lib/Target/PowerPC/PPCSubtarget.h @@ -113,6 +113,7 @@ protected: bool HasPCRelativeMemops; bool HasMMA; bool HasROPProtect; + bool HasPrivileged; bool HasFCPSGN; bool HasFSQRT; bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES; @@ -275,6 +276,7 @@ public: bool hasPCRelativeMemops() const { return HasPCRelativeMemops; } bool hasMMA() const { return HasMMA; } bool hasROPProtect() const { return HasROPProtect; } + bool hasPrivileged() const { return HasPrivileged; } bool pairedVectorMemops() const { return PairedVectorMemops; } bool hasMFOCRF() const { return HasMFOCRF; } bool hasISEL() const { return HasISEL; } diff --git a/test/CodeGen/PowerPC/future-check-features.ll b/test/CodeGen/PowerPC/future-check-features.ll index ea36f5793c9..1dca4dafd5b 100644 --- a/test/CodeGen/PowerPC/future-check-features.ll +++ b/test/CodeGen/PowerPC/future-check-features.ll @@ -1,7 +1,7 @@ -; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect \ +; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect,privileged \ ; RUN: -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \ ; RUN: -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s -; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect \ +; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect,privileged \ ; RUN: -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \ ; RUN: -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s