mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
00e1bbce35
Cleanup handling of the denormal-fp-math attribute. Consolidate places checking the allowed names in one place. This is in preparation for introducing FP type specific variants of the denormal-fp-mode attribute. AMDGPU will switch to using this in place of the current hacky use of subtarget features for the denormal mode. Introduce a new header for dealing with FP modes. The constrained intrinsic classes define related enums that should also be moved into this header for uses in other contexts. The verifier could use a check to make sure the denorm-fp-mode attribute is sane, but there currently isn't one. Currently, DAGCombiner incorrectly asssumes non-IEEE behavior by default in the one current user. Clang must be taught to start emitting this attribute by default to avoid regressions when this is switched to assume ieee behavior if the attribute isn't present.
34 lines
1.2 KiB
C++
34 lines
1.2 KiB
C++
//===- llvm/unittest/ADT/FloatingPointMode.cpp ----------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/ADT/FloatingPointMode.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
|
|
TEST(FloatingPointModeTest, ParseDenormalFPAttribute) {
|
|
EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttribute("ieee"));
|
|
EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttribute(""));
|
|
EXPECT_EQ(DenormalMode::PreserveSign,
|
|
parseDenormalFPAttribute("preserve-sign"));
|
|
EXPECT_EQ(DenormalMode::PositiveZero,
|
|
parseDenormalFPAttribute("positive-zero"));
|
|
EXPECT_EQ(DenormalMode::Invalid, parseDenormalFPAttribute("foo"));
|
|
}
|
|
|
|
TEST(FloatingPointModeTest, DenormalAttributeName) {
|
|
EXPECT_EQ("ieee", denormalModeName(DenormalMode::IEEE));
|
|
EXPECT_EQ("preserve-sign", denormalModeName(DenormalMode::PreserveSign));
|
|
EXPECT_EQ("positive-zero", denormalModeName(DenormalMode::PositiveZero));
|
|
EXPECT_EQ("", denormalModeName(DenormalMode::Invalid));
|
|
}
|
|
|
|
}
|