Path: blob/main/contrib/llvm-project/llvm/lib/Target/PowerPC/MCTargetDesc/PPCPredicates.h
35294 views
//===-- PPCPredicates.h - PPC Branch Predicate Information ------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file describes the PowerPC branch predicates.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCPREDICATES_H13#define LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCPREDICATES_H1415// GCC #defines PPC on Linux but we use it as our namespace name16#undef PPC1718// Generated files will use "namespace PPC". To avoid symbol clash,19// undefine PPC here. PPC may be predefined on some hosts.20#undef PPC2122namespace llvm {23namespace PPC {24/// Predicate - These are "(BI << 5) | BO" for various predicates.25enum Predicate {26PRED_LT = (0 << 5) | 12,27PRED_LE = (1 << 5) | 4,28PRED_EQ = (2 << 5) | 12,29PRED_GE = (0 << 5) | 4,30PRED_GT = (1 << 5) | 12,31PRED_NE = (2 << 5) | 4,32PRED_UN = (3 << 5) | 12,33PRED_NU = (3 << 5) | 4,34PRED_LT_MINUS = (0 << 5) | 14,35PRED_LE_MINUS = (1 << 5) | 6,36PRED_EQ_MINUS = (2 << 5) | 14,37PRED_GE_MINUS = (0 << 5) | 6,38PRED_GT_MINUS = (1 << 5) | 14,39PRED_NE_MINUS = (2 << 5) | 6,40PRED_UN_MINUS = (3 << 5) | 14,41PRED_NU_MINUS = (3 << 5) | 6,42PRED_LT_PLUS = (0 << 5) | 15,43PRED_LE_PLUS = (1 << 5) | 7,44PRED_EQ_PLUS = (2 << 5) | 15,45PRED_GE_PLUS = (0 << 5) | 7,46PRED_GT_PLUS = (1 << 5) | 15,47PRED_NE_PLUS = (2 << 5) | 7,48PRED_UN_PLUS = (3 << 5) | 15,49PRED_NU_PLUS = (3 << 5) | 7,5051// SPE scalar compare instructions always set the GT bit.52PRED_SPE = PRED_GT,5354// When dealing with individual condition-register bits, we have simple set55// and unset predicates.56PRED_BIT_SET = 1024,57PRED_BIT_UNSET = 102558};5960// Bit for branch taken (plus) or not-taken (minus) hint61enum BranchHintBit {62BR_NO_HINT = 0x0,63BR_NONTAKEN_HINT = 0x2,64BR_TAKEN_HINT = 0x3,65BR_HINT_MASK = 0X366};6768/// Invert the specified predicate. != -> ==, < -> >=.69Predicate InvertPredicate(Predicate Opcode);7071/// Assume the condition register is set by MI(a,b), return the predicate if72/// we modify the instructions such that condition register is set by MI(b,a).73Predicate getSwappedPredicate(Predicate Opcode);7475/// Return the condition without hint bits.76inline unsigned getPredicateCondition(Predicate Opcode) {77return (unsigned)(Opcode & ~BR_HINT_MASK);78}7980/// Return the hint bits of the predicate.81inline unsigned getPredicateHint(Predicate Opcode) {82return (unsigned)(Opcode & BR_HINT_MASK);83}8485/// Return predicate consisting of specified condition and hint bits.86inline Predicate getPredicate(unsigned Condition, unsigned Hint) {87return (Predicate)((Condition & ~BR_HINT_MASK) |88(Hint & BR_HINT_MASK));89}90}91}9293#endif949596