brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 19b3161 Raw
104 lines · cpp
1//===------------------------------------------------------------*- C++ -*-===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "GISelMITest.h"10 11namespace llvm {12std::ostream &13operator<<(std::ostream &OS, const LLT Ty) {14  std::string Repr;15  raw_string_ostream SS{Repr};16  Ty.print(SS);17  OS << Repr;18  return OS;19}20 21std::ostream &22operator<<(std::ostream &OS, const MachineFunction &MF) {23  std::string Repr;24  raw_string_ostream SS{Repr};25  MF.print(SS);26  OS << Repr;27  return OS;28}29 30}31 32std::unique_ptr<TargetMachine> AArch64GISelMITest::createTargetMachine() const {33  Triple TargetTriple("aarch64--");34  std::string Error;35  const Target *T = TargetRegistry::lookupTarget("", TargetTriple, Error);36  if (!T)37    return nullptr;38 39  TargetOptions Options;40  return std::unique_ptr<TargetMachine>(41      T->createTargetMachine(TargetTriple, "", "", Options, std::nullopt,42                             std::nullopt, CodeGenOptLevel::Aggressive));43}44 45void AArch64GISelMITest::getTargetTestModuleString(SmallString<512> &S,46                                                   StringRef MIRFunc) const {47  (Twine(R"MIR(48---49...50name: func51tracksRegLiveness: true52registers:53  - { id: 0, class: _ }54  - { id: 1, class: _ }55  - { id: 2, class: _ }56  - { id: 3, class: _ }57body: |58  bb.1:59    liveins: $x0, $x1, $x2, $x460 61    %0(s64) = COPY $x062    %1(s64) = COPY $x163    %2(s64) = COPY $x264)MIR") +65   Twine(MIRFunc) + Twine("...\n"))66      .toNullTerminatedStringRef(S);67}68 69std::unique_ptr<TargetMachine> AMDGPUGISelMITest::createTargetMachine() const {70  Triple TargetTriple("amdgcn-amd-amdhsa");71  std::string Error;72  const Target *T = TargetRegistry::lookupTarget("", TargetTriple, Error);73  if (!T)74    return nullptr;75 76  TargetOptions Options;77  return std::unique_ptr<TargetMachine>(78      T->createTargetMachine(TargetTriple, "gfx900", "", Options, std::nullopt,79                             std::nullopt, CodeGenOptLevel::Aggressive));80}81 82void AMDGPUGISelMITest::getTargetTestModuleString(83  SmallString<512> &S, StringRef MIRFunc) const {84  (Twine(R"MIR(85---86...87name: func88tracksRegLiveness: true89registers:90  - { id: 0, class: _ }91  - { id: 1, class: _ }92  - { id: 2, class: _ }93  - { id: 3, class: _ }94body: |95  bb.1:96    liveins: $vgpr0, $vgpr1, $vgpr297 98    %0(s32) = COPY $vgpr099    %1(s32) = COPY $vgpr1100    %2(s32) = COPY $vgpr2101)MIR") + Twine(MIRFunc) + Twine("...\n"))102                            .toNullTerminatedStringRef(S);103}104