//===-- AArch64BaseInfo.h - Top level definitions for AArch64- --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains small standalone helper functions and enum definitions for
// the AArch64 target useful for the compiler back-end and the MC libraries.
// As such, it deliberately does not include references to LLVM core
// code gen types, passes, etc..
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_AARCH64_BASEINFO_H
#define LLVM_AARCH64_BASEINFO_H
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/ErrorHandling.h"
namespace llvm {
// // Enums corresponding to AArch64 condition codes
namespace A64CC {
// The CondCodes constants map directly to the 4-bit encoding of the
// condition field for predicated instructions.
enum CondCodes { // Meaning (integer) Meaning (floating-point)
EQ = 0, // Equal Equal
NE, // Not equal Not equal, or unordered
HS, // Unsigned higher or same >, ==, or unordered
LO, // Unsigned lower or same Less than
MI, // Minus, negative Less than
PL, // Plus, positive or zero >, ==, or unordered
VS, // Overflow Unordered
VC, // No overflow Ordered
HI, // Unsigned higher Greater than, or unordered
LS, // Unsigned lower or same Less than or equal
GE, // Greater than or equal Greater than or equal
LT, // Less than Less than, or unordered
GT, // Signed greater than Greater than
LE, // Signed less than or equal <, ==, or unordered
AL, // Always (unconditional) Always (unconditional)
NV, // Always (unconditional) Always (unconditional)
// Note the NV exists purely to disassemble 0b1111. Execution
// is "always".
Invalid
};
} // namespace A64CC
inline static const char *A64CondCodeToString(A64CC::CondCodes CC) {
switch (CC) {
default: llvm_unreachable("Unknown condition code");
case A64CC::EQ: return "eq";
case A64CC::NE: return "ne";
case A64CC::HS: return "hs";
case A64CC::LO: return "lo";
case A64CC::MI: return "mi";
case A64CC::PL: return "pl";
case A64CC::VS: return "vs";
case A64CC::VC: return "vc";
case A64CC::HI: return "hi";
case A64CC::LS: return "ls";
case A64CC::GE: return "ge";
case A64CC::LT: return "lt";
case A64CC::GT: return "gt";
case A64CC::LE: return "le";
case A64CC::AL: return "al";
case A64CC::NV: return "nv";
}
}
inline static A64CC::CondCodes A64StringToCondCode(StringRef CondStr) {
return StringSwitch<A64CC::CondCodes>(CondStr.lower())
.Case("eq", A64CC::EQ)
.Case("ne", A64CC::NE)
.Case("ne", A64CC::NE)
.Case("hs", A64CC::HS)
.Case("cs", A64CC::HS)
.Case("lo", A64CC::LO)
.Case("cc", A64CC::LO)
.Case("mi", A64CC::MI)
.Case("pl", A64CC::PL)
.Case("vs", A64CC::VS)
.Case("vc", A64CC::VC)
.Case("hi", A64CC::HI)
.Case("ls", A64CC::LS)
.Case("ge", A64CC::GE)
.Case("lt", A64CC::LT)
.Case("gt", A64CC::GT)
.Case("le", A64CC::LE)
.Case("al", A64CC::AL)
.Case("nv", A64CC::NV)
.Default(A64CC::Invalid);
}
inline static A64CC::CondCodes A64InvertCondCode(A64CC::CondCodes CC) {
// It turns out that the condition codes have been designed so that in order
// to reverse the intent of the condition you only have to invert the low