blob: cc782ab59d1c24bdbe59bc9fa6ec5c1503631dce [file] [log] [blame]
//===- subzero/src/IceTypes.h - Primitive ICE types -------------*- C++ -*-===//
//
// The Subzero Code Generator
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares a few properties of the primitive types allowed
// in Subzero. Every Subzero source file is expected to include
// IceTypes.h.
//
//===----------------------------------------------------------------------===//
#ifndef SUBZERO_SRC_ICETYPES_H
#define SUBZERO_SRC_ICETYPES_H
#include "IceTypes.def"
namespace Ice {
enum Type {
#define X(tag, size, align, elts, elty, str) tag,
ICETYPE_TABLE
#undef X
IceType_NUM
};
enum TargetArch {
Target_X8632,
Target_X8664,
Target_ARM32,
Target_ARM64
};
enum OptLevel {
Opt_m1,
Opt_0,
Opt_1,
Opt_2
};
size_t typeWidthInBytes(Type Ty);
size_t typeAlignInBytes(Type Ty);
size_t typeNumElements(Type Ty);
Type typeElementType(Type Ty);
const char *typeString(Type Ty);
bool isVectorType(Type Ty);
bool isIntegerType(Type Ty); // scalar or vector
bool isScalarIntegerType(Type Ty);
bool isVectorIntegerType(Type Ty);
bool isIntegerArithmeticType(Type Ty);
bool isFloatingType(Type Ty); // scalar or vector
bool isScalarFloatingType(Type Ty);
bool isVectorFloatingType(Type Ty);
/// Returns true if the given type can be used in a load instruction.
bool isLoadStoreType(Type Ty);
/// Returns type generated by applying the compare instructions (icmp and fcmp)
/// to arguments of the given type. Returns IceType_void if compare is not
/// allowed.
Type getCompareResultType(Type Ty);
/// Returns the number of bits in a scalar integer type.
SizeT getScalarIntBitWidth(Type Ty);
template <typename StreamType>
inline StreamType &operator<<(StreamType &Str, const Type &Ty) {
Str << typeString(Ty);
return Str;
}
} // end of namespace Ice
#endif // SUBZERO_SRC_ICETYPES_H