• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- SPIRVValue.cpp � Class to represent a SPIR-V Value --------*- C++ -*-===//
2 //
3 //                     The LLVM/SPIRV 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) 2014 Advanced Micro Devices, Inc. All rights reserved.
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 Advanced Micro Devices, Inc., 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 /// \file
35 ///
36 /// This file defines the values defined in SPIR-V spec with op codes.
37 ///
38 /// The name of the SPIR-V values follow the op code name in the spec.
39 /// This is for readability and ease of using macro to handle types.
40 //
41 //===----------------------------------------------------------------------===//
42 
43 #include "SPIRVValue.h"
44 #include "SPIRVEnum.h"
45 namespace SPIRV{
46 void
setAlignment(SPIRVWord A)47 SPIRVValue::setAlignment(SPIRVWord A) {
48   if (A == 0) {
49     eraseDecorate(DecorationAlignment);
50     return;
51   }
52   addDecorate(new SPIRVDecorate(DecorationAlignment, this, A));
53   SPIRVDBG(spvdbgs() << "Set alignment " << A << " for obj " << Id << "\n")
54 }
55 
56 bool
hasAlignment(SPIRVWord * Result) const57 SPIRVValue::hasAlignment(SPIRVWord *Result)const {
58   return hasDecorate(DecorationAlignment, 0, Result);
59 }
60 
61 bool
isVolatile() const62 SPIRVValue::isVolatile()const {
63   return hasDecorate(DecorationVolatile);
64 }
65 
66 void
setVolatile(bool IsVolatile)67 SPIRVValue::setVolatile(bool IsVolatile) {
68   if (!IsVolatile) {
69     eraseDecorate(DecorationVolatile);
70     return;
71   }
72   addDecorate(new SPIRVDecorate(DecorationVolatile, this));
73   SPIRVDBG(spvdbgs() << "Set volatile " << " for obj " << Id << "\n")
74 }
75 
76 }
77