TargetIntrinsicInfo.h revision 360660
1219019Sgabor//===-- llvm/Target/TargetIntrinsicInfo.h - Instruction Info ----*- C++ -*-===//
2219019Sgabor//
3219019Sgabor// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4219019Sgabor// See https://llvm.org/LICENSE.txt for license information.
5219019Sgabor// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6219019Sgabor//
7219019Sgabor//===----------------------------------------------------------------------===//
8219019Sgabor//
9219019Sgabor// This file describes the target intrinsic instructions to the code generator.
10219019Sgabor//
11219019Sgabor//===----------------------------------------------------------------------===//
12219019Sgabor
13219019Sgabor#ifndef LLVM_TARGET_TARGETINTRINSICINFO_H
14219019Sgabor#define LLVM_TARGET_TARGETINTRINSICINFO_H
15219019Sgabor
16219019Sgabor#include "llvm/ADT/StringRef.h"
17219019Sgabor#include "llvm/Support/Compiler.h"
18219019Sgabor#include <string>
19219019Sgabor
20219019Sgabornamespace llvm {
21219019Sgabor
22219019Sgaborclass Function;
23219019Sgaborclass Module;
24219019Sgaborclass Type;
25219019Sgabor
26219019Sgabor//---------------------------------------------------------------------------
27219019Sgabor///
28219019Sgabor/// TargetIntrinsicInfo - Interface to description of machine instruction set
29219019Sgabor///
30219019Sgaborclass TargetIntrinsicInfo {
31219019Sgabor  TargetIntrinsicInfo(const TargetIntrinsicInfo &) = delete;
32219019Sgabor  void operator=(const TargetIntrinsicInfo &) = delete;
33219019Sgaborpublic:
34219019Sgabor  TargetIntrinsicInfo();
35219019Sgabor  virtual ~TargetIntrinsicInfo();
36219019Sgabor
37219019Sgabor  /// Return the name of a target intrinsic, e.g. "llvm.bfin.ssync".
38219019Sgabor  /// The Tys and numTys parameters are for intrinsics with overloaded types
39219019Sgabor  /// (e.g., those using iAny or fAny). For a declaration for an overloaded
40219019Sgabor  /// intrinsic, Tys should point to an array of numTys pointers to Type,
41219019Sgabor  /// and must provide exactly one type for each overloaded type in the
42219019Sgabor  /// intrinsic.
43219019Sgabor  virtual std::string getName(unsigned IID, Type **Tys = nullptr,
44219019Sgabor                              unsigned numTys = 0) const = 0;
45219019Sgabor
46219019Sgabor  /// Look up target intrinsic by name. Return intrinsic ID or 0 for unknown
47219019Sgabor  /// names.
48219019Sgabor  virtual unsigned lookupName(const char *Name, unsigned Len) const =0;
49219019Sgabor
50219019Sgabor  unsigned lookupName(StringRef Name) const {
51219019Sgabor    return lookupName(Name.data(), Name.size());
52219019Sgabor  }
53219019Sgabor
54219019Sgabor  /// Return the target intrinsic ID of a function, or 0.
55219019Sgabor  virtual unsigned getIntrinsicID(const Function *F) const;
56219019Sgabor
57219019Sgabor  /// Returns true if the intrinsic can be overloaded.
58219019Sgabor  virtual bool isOverloaded(unsigned IID) const = 0;
59219019Sgabor
60219019Sgabor  /// Create or insert an LLVM Function declaration for an intrinsic,
61219019Sgabor  /// and return it. The Tys and numTys are for intrinsics with overloaded
62219019Sgabor  /// types. See above for more information.
63219019Sgabor  virtual Function *getDeclaration(Module *M, unsigned ID, Type **Tys = nullptr,
64219019Sgabor                                   unsigned numTys = 0) const = 0;
65219019Sgabor};
66219019Sgabor
67219019Sgabor} // End llvm namespace
68219019Sgabor
69219019Sgabor#endif
70219019Sgabor