Path: blob/main/contrib/llvm-project/llvm/tools/llvm-remarkutil/RemarkUtilHelpers.h
35230 views
//===- RemarkUtilHelpers.h ------------------------------------------------===//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// Helpers for remark utilites9//10//===----------------------------------------------------------------------===//11#include "llvm-c/Remarks.h"12#include "llvm/ADT/StringRef.h"13#include "llvm/Remarks/Remark.h"14#include "llvm/Remarks/RemarkFormat.h"15#include "llvm/Remarks/RemarkParser.h"16#include "llvm/Remarks/YAMLRemarkSerializer.h"17#include "llvm/Support/Error.h"18#include "llvm/Support/FileSystem.h"19#include "llvm/Support/MemoryBuffer.h"20#include "llvm/Support/ToolOutputFile.h"2122// Keep input + output help + names consistent across the various modes via a23// hideous macro.24#define INPUT_OUTPUT_COMMAND_LINE_OPTIONS(SUBOPT) \25static cl::opt<std::string> InputFileName(cl::Positional, cl::init("-"), \26cl::desc("<input file>"), \27cl::sub(SUBOPT)); \28static cl::opt<std::string> OutputFileName( \29"o", cl::init("-"), cl::desc("Output"), cl::value_desc("filename"), \30cl::sub(SUBOPT));3132// Keep Input format and names consistent accross the modes via a macro.33#define INPUT_FORMAT_COMMAND_LINE_OPTIONS(SUBOPT) \34static cl::opt<Format> InputFormat( \35"parser", cl::desc("Input remark format to parse"), \36cl::values(clEnumValN(Format::YAML, "yaml", "YAML"), \37clEnumValN(Format::Bitstream, "bitstream", "Bitstream")), \38cl::sub(SUBOPT));3940#define DEBUG_LOC_INFO_COMMAND_LINE_OPTIONS(SUBOPT) \41static cl::opt<bool> UseDebugLoc( \42"use-debug-loc", \43cl::desc( \44"Add debug loc information when generating tables for " \45"functions. The loc is represented as (path:line number:column " \46"number)"), \47cl::init(false), cl::sub(SUBOPT));4849namespace llvm {50namespace remarks {51Expected<std::unique_ptr<MemoryBuffer>>52getInputMemoryBuffer(StringRef InputFileName);53Expected<std::unique_ptr<ToolOutputFile>>54getOutputFileWithFlags(StringRef OutputFileName, sys::fs::OpenFlags Flags);55Expected<std::unique_ptr<ToolOutputFile>>56getOutputFileForRemarks(StringRef OutputFileName, Format OutputFormat);57} // namespace remarks58} // namespace llvm596061