Add boolean constants
This commit is contained in:
parent
7580d729c6
commit
bf52ad2d9f
5 changed files with 34 additions and 1 deletions
|
@ -120,6 +120,14 @@ public:
|
|||
/// Returns type pipe.
|
||||
const Op* TypePipe(spv::AccessQualifier access_qualifier);
|
||||
|
||||
// Constant
|
||||
|
||||
/// Returns a true scalar constant.
|
||||
const Op* ConstantTrue(const Op* result_type);
|
||||
|
||||
/// Returns a false scalar constant.
|
||||
const Op* ConstantFalse(const Op* result_type);
|
||||
|
||||
// Function
|
||||
|
||||
/// Emits a function.
|
||||
|
|
|
@ -10,6 +10,7 @@ add_library(sirit
|
|||
common_types.h
|
||||
opcodes.h
|
||||
opcodes/type.cpp
|
||||
opcodes/constant.cpp
|
||||
opcodes/function.cpp
|
||||
opcodes/flow.cpp
|
||||
)
|
||||
|
|
21
src/opcodes/constant.cpp
Normal file
21
src/opcodes/constant.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* This file is part of the sirit project.
|
||||
* Copyright (c) 2018 ReinUsesLisp
|
||||
* This software may be used and distributed according to the terms of the GNU
|
||||
* General Public License version 2 or any later version.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include "sirit/sirit.h"
|
||||
#include "opcodes.h"
|
||||
|
||||
namespace Sirit {
|
||||
|
||||
const Op* Module::ConstantTrue(const Op* result_type) {
|
||||
return AddDeclaration(new Op(spv::Op::OpConstantTrue, bound, result_type));
|
||||
}
|
||||
|
||||
const Op* Module::ConstantFalse(const Op* result_type) {
|
||||
return AddDeclaration(new Op(spv::Op::OpConstantFalse, bound, result_type));
|
||||
}
|
||||
|
||||
} // namespace Sirit
|
|
@ -227,7 +227,7 @@ const Op* Module::TypeQueue() {
|
|||
const Op* Module::TypePipe(spv::AccessQualifier access_qualifier) {
|
||||
AddCapability(spv::Capability::Pipes);
|
||||
Op* op{new Op(spv::Op::OpTypePipe, bound)};
|
||||
op->Add(static_cast<u32>(access_qualifier);
|
||||
op->Add(static_cast<u32>(access_qualifier));
|
||||
return AddDeclaration(op);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@ public:
|
|||
TypeRuntimeArray(TypeInt(32, true));
|
||||
TypeStruct({TypeInt(32, true), TypeFloat(64)});
|
||||
TypePointer(spv::StorageClass::Private, TypeFloat(16));
|
||||
ConstantTrue(TypeBool());
|
||||
ConstantTrue(TypeBool());
|
||||
ConstantFalse(TypeBool());
|
||||
|
||||
auto main_type{TypeFunction(TypeVoid())};
|
||||
auto main_func{Emit(Function(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type))};
|
||||
|
|
Loading…
Reference in a new issue