Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/lib/SPIRV/SPIRVLowerSaddWithOverflow.h

raw
1 //===- SPIRVLowerSaddWithOverflowBase.h - sadd lowering --------*- C++ -*-===//
2 //
3 // The LLVM/SPIR-V Translator
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 // Copyright (c) 2022 The Khronos Group Inc.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal with the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // Redistributions of source code must retain the above copyright notice,
18 // this list of conditions and the following disclaimers.
19 // Redistributions in binary form must reproduce the above copyright notice,
20 // this list of conditions and the following disclaimers in the documentation
21 // and/or other materials provided with the distribution.
22 // Neither the names of The Khronos Group, nor the names of its
23 // contributors may be used to endorse or promote products derived from this
24 // Software without specific prior written permission.
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH
31 // THE SOFTWARE.
32 //
33 //===----------------------------------------------------------------------===//
34
35 #ifndef SPIRV_SPIRVLOWERSADDWITHOVERFLOW_H
36 #define SPIRV_SPIRVLOWERSADDWITHOVERFLOW_H
37
38 #include "llvm/IR/InstVisitor.h"
39 #include "llvm/IR/PassManager.h"
40 #include "llvm/Pass.h"
41
42 namespace SPIRV {
43
44 class SPIRVLowerSaddWithOverflowBase
45 : public llvm::InstVisitor<SPIRVLowerSaddWithOverflowBase> {
46 public:
47 SPIRVLowerSaddWithOverflowBase() : Context(nullptr), Mod(nullptr) {}
48 virtual ~SPIRVLowerSaddWithOverflowBase() {}
49 virtual void visitIntrinsicInst(llvm::CallInst &I);
50
51 bool runLowerSaddWithOverflow(llvm::Module &M);
52
53 private:
54 llvm::LLVMContext *Context;
55 llvm::Module *Mod;
56 bool TheModuleIsModified = false;
57 };
58
59 class SPIRVLowerSaddWithOverflowPass
60 : public llvm::PassInfoMixin<SPIRVLowerSaddWithOverflowPass>,
61 public SPIRVLowerSaddWithOverflowBase {
62 public:
63 llvm::PreservedAnalyses run(llvm::Module &M,
64 llvm::ModuleAnalysisManager &MAM);
65 };
66
67 class SPIRVLowerSaddWithOverflowLegacy : public llvm::ModulePass,
68 public SPIRVLowerSaddWithOverflowBase {
69 public:
70 SPIRVLowerSaddWithOverflowLegacy();
71
72 bool runOnModule(llvm::Module &M) override;
73
74 static char ID;
75 };
76
77 } // namespace SPIRV
78
79 #endif // SPIRV_SPIRVLOWERSADDWITHOVERFLOW_H