brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 6672305 Raw
87 lines · c
1//===---- MCATestBase.h -----------------------------------------*- 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// Test fixture common to all MCA tests.9//===----------------------------------------------------------------------===//10 11#ifndef LLVM_UNITTESTS_TOOLS_LLVMMCA_MCATESTBASE_H12#define LLVM_UNITTESTS_TOOLS_LLVMMCA_MCATESTBASE_H13 14#include "llvm/ADT/StringRef.h"15#include "llvm/MC/MCAsmInfo.h"16#include "llvm/MC/MCContext.h"17#include "llvm/MC/MCInst.h"18#include "llvm/MC/MCInstPrinter.h"19#include "llvm/MC/MCInstrAnalysis.h"20#include "llvm/MC/MCInstrInfo.h"21#include "llvm/MC/MCObjectFileInfo.h"22#include "llvm/MC/MCRegisterInfo.h"23#include "llvm/MC/MCSubtargetInfo.h"24#include "llvm/MC/MCTargetOptions.h"25#include "llvm/MC/TargetRegistry.h"26#include "llvm/MCA/Context.h"27#include "llvm/MCA/InstrBuilder.h"28#include "llvm/TargetParser/SubtargetFeature.h"29#include "llvm/TargetParser/Triple.h"30 31#include "gtest/gtest.h"32 33namespace llvm {34namespace json {35class Object;36} // end namespace json37 38namespace mca {39class View;40 41class MCATestBase : public ::testing::Test {42protected:43  // Note: Subclass ctors are expected to perform target-specific44  // initializations.45  MCATestBase(StringRef TripleStr, StringRef CPUName, StringRef MAttr = "")46      : TheTriple(TripleStr), CPUName(CPUName), MAttr(MAttr) {}47 48  /// Factory function to create a Target.49  virtual const Target *getLLVMTarget() const;50 51  /// Factory function to create a MCTargetOptions instance. Returns an52  /// empty one by default.53  virtual MCTargetOptions getMCTargetOptions() { return MCTargetOptions(); }54 55  const Target *TheTarget;56  const Triple TheTriple;57  StringRef CPUName;58  StringRef MAttr;59 60  // MC components.61  std::unique_ptr<MCSubtargetInfo> STI;62  std::unique_ptr<MCRegisterInfo> MRI;63  std::unique_ptr<MCAsmInfo> MAI;64  std::unique_ptr<MCObjectFileInfo> MOFI;65  std::unique_ptr<MCContext> Ctx;66  std::unique_ptr<MCInstrInfo> MCII;67  std::unique_ptr<MCInstrAnalysis> MCIA;68  std::unique_ptr<MCInstPrinter> IP;69 70  static mca::PipelineOptions getDefaultPipelineOptions();71 72  void SetUp() override;73 74  /// Utility function to run MCA with (nearly) the same configuration as the75  /// `llvm-mca` tool to verify result correctness.76  /// This function only displays on SummaryView by default.77  virtual Error78  runBaselineMCA(json::Object &Result, ArrayRef<MCInst> Insts,79                 ArrayRef<mca::View *> Views = {},80                 const mca::PipelineOptions *PO = nullptr,81                 ArrayRef<std::pair<StringRef, StringRef>> Descs = {});82};83 84} // end namespace mca85} // end namespace llvm86#endif87