1
0
Fork 0
mirror of https://git.suyu.dev/suyu/sirit.git synced 2024-12-22 20:22:02 +00:00

Add boolean constants

This commit is contained in:
ReinUsesLisp 2018-08-26 19:35:48 -03:00
parent 7580d729c6
commit bf52ad2d9f
5 changed files with 34 additions and 1 deletions

View file

@ -120,6 +120,14 @@ public:
/// Returns type pipe. /// Returns type pipe.
const Op* TypePipe(spv::AccessQualifier access_qualifier); 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 // Function
/// Emits a function. /// Emits a function.

View file

@ -10,6 +10,7 @@ add_library(sirit
common_types.h common_types.h
opcodes.h opcodes.h
opcodes/type.cpp opcodes/type.cpp
opcodes/constant.cpp
opcodes/function.cpp opcodes/function.cpp
opcodes/flow.cpp opcodes/flow.cpp
) )

21
src/opcodes/constant.cpp Normal file
View 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

View file

@ -227,7 +227,7 @@ const Op* Module::TypeQueue() {
const Op* Module::TypePipe(spv::AccessQualifier access_qualifier) { const Op* Module::TypePipe(spv::AccessQualifier access_qualifier) {
AddCapability(spv::Capability::Pipes); AddCapability(spv::Capability::Pipes);
Op* op{new Op(spv::Op::OpTypePipe, bound)}; 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); return AddDeclaration(op);
} }

View file

@ -38,6 +38,9 @@ public:
TypeRuntimeArray(TypeInt(32, true)); TypeRuntimeArray(TypeInt(32, true));
TypeStruct({TypeInt(32, true), TypeFloat(64)}); TypeStruct({TypeInt(32, true), TypeFloat(64)});
TypePointer(spv::StorageClass::Private, TypeFloat(16)); TypePointer(spv::StorageClass::Private, TypeFloat(16));
ConstantTrue(TypeBool());
ConstantTrue(TypeBool());
ConstantFalse(TypeBool());
auto main_type{TypeFunction(TypeVoid())}; auto main_type{TypeFunction(TypeVoid())};
auto main_func{Emit(Function(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type))}; auto main_func{Emit(Function(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type))};