llvm/llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h

//===--- ppc64.h - Generic JITLink ppc64 edge kinds, utilities --*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// Generic utilities for graphs representing 64-bit PowerPC objects.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_EXECUTIONENGINE_JITLINK_PPC64_H
#define LLVM_EXECUTIONENGINE_JITLINK_PPC64_H

#include "llvm/ExecutionEngine/JITLink/JITLink.h"
#include "llvm/ExecutionEngine/JITLink/TableManager.h"
#include "llvm/Support/Endian.h"

namespace llvm::jitlink::ppc64 {

/// Represents ppc64 fixups and other ppc64-specific edge kinds.
enum EdgeKind_ppc64 : Edge::Kind {};

enum PLTCallStubKind {};

extern const char NullPointerContent[8];
extern const char PointerJumpStubContent_big[20];
extern const char PointerJumpStubContent_little[20];
extern const char PointerJumpStubNoTOCContent_big[32];
extern const char PointerJumpStubNoTOCContent_little[32];

struct PLTCallStubReloc {};

struct PLTCallStubInfo {};

template <llvm::endianness Endianness>
inline PLTCallStubInfo pickStub(PLTCallStubKind StubKind) {}

inline Symbol &createAnonymousPointer(LinkGraph &G, Section &PointerSection,
                                      Symbol *InitialTarget = nullptr,
                                      uint64_t InitialAddend = 0) {}

template <llvm::endianness Endianness>
inline Symbol &createAnonymousPointerJumpStub(LinkGraph &G,
                                              Section &StubSection,
                                              Symbol &PointerSymbol,
                                              PLTCallStubKind StubKind) {}

template <llvm::endianness Endianness>
class TOCTableManager : public TableManager<TOCTableManager<Endianness>> {};

template <llvm::endianness Endianness>
class PLTTableManager : public TableManager<PLTTableManager<Endianness>> {};

/// Returns a string name for the given ppc64 edge. For debugging purposes
/// only.
const char *getEdgeKindName(Edge::Kind K);

inline static uint16_t ha(uint64_t x) {}
inline static uint64_t lo(uint64_t x) {}
inline static uint16_t hi(uint64_t x) {}
inline static uint64_t high(uint64_t x) {}
inline static uint64_t higha(uint64_t x) {}
inline static uint64_t higher(uint64_t x) {}
inline static uint64_t highera(uint64_t x) {}
inline static uint16_t highest(uint64_t x) {}
inline static uint16_t highesta(uint64_t x) {}

// Prefixed instruction introduced in ISAv3.1 consists of two 32-bit words,
// prefix word and suffix word, i.e., prefixed_instruction = concat(prefix_word,
// suffix_word). That's to say, for a prefixed instruction encoded in uint64_t,
// the most significant 32 bits belong to the prefix word. The prefix word is at
// low address for both big/little endian. Byte order in each word still follows
// its endian.
template <llvm::endianness Endianness>
inline static uint64_t readPrefixedInstruction(const char *Loc) {}

template <llvm::endianness Endianness>
inline static void writePrefixedInstruction(char *Loc, uint64_t Inst) {}

template <llvm::endianness Endianness>
inline Error relocateHalf16(char *FixupPtr, int64_t Value, Edge::Kind K) {}

/// Apply fixup expression for edge to block content.
template <llvm::endianness Endianness>
inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
                        const Symbol *TOCSymbol) {}

} // end namespace llvm::jitlink::ppc64

#endif // LLVM_EXECUTIONENGINE_JITLINK_PPC64_H