LLVM 24.0.0git
PISABaseInfo.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file declares common definitions used by the PISA MC components.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_PISA_MCTARGETDESC_PISABASEINFO_H
15#define LLVM_LIB_TARGET_PISA_MCTARGETDESC_PISABASEINFO_H
16
17#include <cassert>
18#include <cstdint>
19#include <string>
20
21namespace llvm {
22
23// Return a string representation of the operands from startIndex onwards.
24// Templated to allow both MachineInstr and MCInst to use the same logic.
25template <class InstType>
26std::string getPISAStringOperand(const InstType &MI, unsigned StartIndex) {
27 std::string S; // Iteratively append to this string.
28
29 const unsigned NumOps = MI.getNumOperands();
30 bool IsFinished = false;
31 for (unsigned I = StartIndex; I < NumOps && !IsFinished; ++I) {
32 if (!MI.getOperand(I).isImm()) // Stop if we hit a register operand.
33 break;
34 assert((MI.getOperand(I).getImm() >> 32) == 0 &&
35 "Imm operand should be i32 word");
36 const uint32_t Imm =
37 MI.getOperand(I).getImm(); // Each i32 word is up to 4 characters.
38 for (unsigned ShiftAmount = 0; ShiftAmount < 32; ShiftAmount += 8) {
39 char C = (Imm >> ShiftAmount) & 0xff;
40 if (C == 0) { // Stop if we hit a null-terminator character.
41 IsFinished = true;
42 break;
43 }
44 S += C; // Otherwise, append the character to the result string.
45 }
46 }
47 return S;
48}
49} // namespace llvm
50#endif // LLVM_LIB_TARGET_PISA_MCTARGETDESC_PISABASEINFO_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t Imm
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
IRTranslator LLVM IR MI
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
#define I(x, y, z)
Definition MD5.cpp:57
This is an optimization pass for GlobalISel generic memory operations.
std::string getPISAStringOperand(const InstType &MI, unsigned StartIndex)