[WebAssembly] Add target flags for sign-ext opcodes.

Add -msign-ext and -mno-sign-ext to control the new sign-ext target
feature.

llvm-svn: 322967
This commit is contained in:
Dan Gohman 2018-01-19 17:16:32 +00:00
parent 5d2b9354b1
commit d0c4e1e9fc
4 changed files with 17 additions and 1 deletions

View File

@ -2320,6 +2320,8 @@ WebAssembly
-----------
.. option:: -mnontrapping-fptoint, -mno-nontrapping-fptoint
.. option:: -msign-ext, -mno-sign-ext
.. option:: -msimd128, -mno-simd128
X86

View File

@ -1870,6 +1870,8 @@ def msimd128 : Flag<["-"], "msimd128">, Group<m_wasm_Features_Group>;
def mno_simd128 : Flag<["-"], "mno-simd128">, Group<m_wasm_Features_Group>;
def mnontrapping_fptoint : Flag<["-"], "mnontrapping-fptoint">, Group<m_wasm_Features_Group>;
def mno_nontrapping_fptoint : Flag<["-"], "mno-nontrapping-fptoint">, Group<m_wasm_Features_Group>;
def msign_ext : Flag<["-"], "msign-ext">, Group<m_wasm_Features_Group>;
def mno_sign_ext : Flag<["-"], "mno-sign-ext">, Group<m_wasm_Features_Group>;
def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
Flags<[HelpHidden]>,

View File

@ -33,6 +33,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
return llvm::StringSwitch<bool>(Feature)
.Case("simd128", SIMDLevel >= SIMD128)
.Case("nontrapping-fptoint", HasNontrappingFPToInt)
.Case("sign-ext", HasSignExt)
.Default(false);
}
@ -70,6 +71,14 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
HasNontrappingFPToInt = false;
continue;
}
if (Feature == "+sign-ext") {
HasSignExt = true;
continue;
}
if (Feature == "-sign-ext") {
HasSignExt = false;
continue;
}
Diags.Report(diag::err_opt_not_valid_with_opt)
<< Feature << "-target-feature";

View File

@ -31,10 +31,12 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public TargetInfo {
} SIMDLevel;
bool HasNontrappingFPToInt;
bool HasSignExt;
public:
explicit WebAssemblyTargetInfo(const llvm::Triple &T, const TargetOptions &)
: TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false) {
: TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false),
HasSignExt(false) {
NoAsmVariants = true;
SuitableAlign = 128;
LargeArrayMinWidth = 128;
@ -60,6 +62,7 @@ private:
if (CPU == "bleeding-edge") {
Features["simd128"] = true;
Features["nontrapping-fptoint"] = true;
Features["sign-ext"] = true;
}
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
}