Commit graph

164 commits

Author SHA1 Message Date
ReinUsesLisp
ef47087d88 literal_number: Use static_cast instead of dynamic_cast 2019-11-01 05:12:54 -03:00
ReinUsesLisp
a1972e35f1 instructions/logical: Silence -Wpedantic 2019-10-24 03:08:42 -03:00
ReinUsesLisp
42248408a9 Remove Emit entry in favor of auto-emitting code
All instructions but OpVariable and OpLabel are automatically emitted.
These functions have to call AddLocalVariable/AddGlobalVariable or
AddLabel respectively.
2019-10-18 04:27:52 -03:00
ReinUsesLisp
8cf3d225db Assemble uint32_t instead of uint8_t
Vulkan receives SPIR-V modules with a uint32_t alignment. Returning
uint8_t forced users to invoke undefined behaviour (reinterpret_cast)
or copy.
2019-10-18 03:46:47 -03:00
Lioncash
ab507033db common_types: Include types within the Sirit namespace
Avoids dumping types into global scope.
2019-10-06 20:55:15 +00:00
ReinUsesLisp
6e14d37386 Add asserts against nullptr operands 2019-09-11 01:19:53 -03:00
ReinUsesLisp
d24685ebd3 Revert "operand: Implement operand hashing and use hashed set for declarations"
This reverts commit 1e665afa36.
2019-09-09 16:48:05 -03:00
ReinUsesLisp
58c5406436 Revert "Fix declarations hashing"
This reverts commit bb6a3421d2.
2019-09-09 16:47:58 -03:00
ReinUsesLisp
bb6a3421d2 Fix declarations hashing 2019-09-09 16:46:46 -03:00
ReinUsesLisp
ae7c664016 Add OpAny and OpAll 2019-09-09 16:46:36 -03:00
ReinUsesLisp
4a0c6e03e1 Add OpVectorExtractDynamic and OpVectorInsertDynamic 2019-09-09 15:42:47 -03:00
ReinUsesLisp
60a856d266 Relicense to The BSD 3-clause license 2019-07-14 18:50:44 -03:00
ReinUsesLisp
1e665afa36 operand: Implement operand hashing and use hashed set for declarations
Instead of manually searching each element in the declarations vector,
use an unordered_set to emplace new declarations avoiding repetition.
2019-06-08 05:23:15 -03:00
Lioncash
f7c4b07a7e stream: Insert supplied string in one operation
Like the other overloads, we can insert the whole string within one
operation instead of doing a byte-by-byte append.

We only do byte-by-byte appending when padding is necessary.
2019-03-16 02:51:35 -03:00
Lioncash
59f795bd6d stream: Change std::string overload for Write to use a std::string_view
Allows various string types to be used with the overload without
constructing a std::string (such as const char* etc).
2019-03-16 02:51:35 -03:00
Lioncash
326c69896b stream: Get rid of undefined behavior
It's undefined behavior to cast down to any other type and dereference
that pointer unless:

1. It's similar (*extremely* vague definition at face value, see below
   for clarification)

2. The casted to type is either the signed/unsigned variant of the
   original type. (e.g. it's fine to cast an int* to an unsigned int*
   and vice-versa).

3. The casted to pointer type is either std::byte*, char*, or unsigned
   char*.

With regards to type similarity, two types (X and Y) are considered
"similar" if:

1. They're the same type (naturally)

2. They're both pointers and the pointed-to types are similar (basically
   1. but for pointers)

3. They're both pointers to members of the same class and the types of
   the pointed-to members are similar in type.

4. They're both arrays of the same size or both arrays of unknown size
   *and* the array element types are similar.

Plus, doing it this way doesn't do a byte-by-byte appending to the
underlying std::vector and instead allocates all the necessary memory up
front and slaps the elements at the end of it.
2019-03-14 21:44:37 -03:00
Lioncash
47d85b81a7 CMakeLists: Apply compilation flags to the sirit target
Previously this wasn't utilizing any of the compiler flags, meaning it
wasn't applying any of the specified warnings.

Since applying the warnings to the target, this uncovered a few warning
cases, such as shadowing class variables on MSVC, etc, which have been fixed.
2019-03-14 19:30:54 -03:00
Lioncash
f6f5913b5f op: Use std::vector's insert member function within vector variant of Add()
While looping here does work fine, it's mildly inefficient, particularly
if the number of members being added is large, because it can result in
multiple allocations over the period of the insertion, depending on how
much extra memory push_back may allocate for successive elements.

Instead, we can just tell the std::vector that we want to slap the whole
contained sequence at the back of it with insert, which lets it allocate
the whole memory block in one attempt.
2019-03-14 04:31:14 -03:00
Lioncash
6fd44e494c Pass std::string by value where applicable.
By taking the std::string by value in the constructor, this allows for
certain situations where copies can be elided entirely (when moving an
instance into the constructor)

e.g.

std::string var = ...

...

... = LiteralString(std::move(var)) // Or whatever other initialization
                                    // is done.

No copy will be done in this case, the move transfers it into the
constructor, and then the move within the initializer list transfers it
into the member variable.

tl;dr: This allows the calling code to potentially construct less
std::string instances by allowing moving into the parameters themselves.
2019-03-14 04:30:39 -03:00
ReinUsesLisp
d5c37d242a
Merge pull request #11 from lioncash/default
operand: Append default to the default constructor
2019-03-14 03:53:31 -03:00
Lioncash
260183a2c7 operand: Append default to the default constructor
Makes it consistent with the destructor.
2019-03-14 02:50:07 -04:00
ReinUsesLisp
3ec2231f9a
Merge pull request #9 from lioncash/unused
sirit: Remove unused variable in AddAnnotation()
2019-03-14 03:49:20 -03:00
Lioncash
984b731e17 op: Amend constructor initializer list order
Amends the order of the initializer list to be structured the same way
the members are ordered.

Silences a -Wreorder warning.
2019-03-14 02:45:57 -04:00
Lioncash
1081bcdda9 sirit: Remove unused variable in AddAnnotation()
id isn't used within AddAnnotation, so this can be removed.
2019-03-14 02:43:05 -04:00
Lioncash
11b7743c29 src: Amend missing override specifiers 2019-03-14 02:25:57 -04:00
ReinUsesLisp
057b100a68 Assert on empty Emit 2019-03-13 19:20:29 -03:00
ReinUsesLisp
1c06f8530e Remove Op prefix on Type instructions 2019-03-13 18:32:38 -03:00
ReinUsesLisp
4b1c1d1e38 Add ellipsis overloads for instructions ending in vectors 2019-03-11 04:38:09 -03:00
ReinUsesLisp
ba92d8ea08 Update README.md and remove automatic capabilities addition 2019-03-11 03:41:44 -03:00
ReinUsesLisp
73595f4588 Change clang-format settings 2019-03-11 03:26:21 -03:00
ReinUsesLisp
38838c9a9d Sort macro defitions for image instructions 2019-03-11 03:19:59 -03:00
ReinUsesLisp
88191480a8 Remove undefined behaviour from literal number 2019-03-11 03:19:59 -03:00
ReinUsesLisp
b23716087a Add OpExtension 2019-03-08 21:09:11 -03:00
ReinUsesLisp
2b0a59d890 Add OpSwitch 2019-01-05 23:58:43 -03:00
ReinUsesLisp
e7971b4451 Add OpExecutionMode 2018-12-04 21:30:32 -03:00
ReinUsesLisp
3641e1de45 Add OpKill 2018-12-02 22:57:55 -03:00
ReinUsesLisp
93d42e62da Remove WriteEnum abstraction 2018-11-16 04:21:37 -03:00
ReinUsesLisp
9d787510d3 Fixup assert formatting 2018-11-16 04:21:01 -03:00
ReinUsesLisp
f259019494 Rename "insts" directory to "instructions" 2018-11-16 04:15:48 -03:00
ReinUsesLisp
f5944d61a6 Upgrade from LGPLv2.1 to LGPLv3 2018-11-16 04:10:10 -03:00
ReinUsesLisp
174263d906
Merge pull request #5 from FernandoS27/image
Implemented Image Instructions
2018-11-13 20:06:13 -03:00
FernandoS27
0318449d65 Implemented Image Instructions 2018-11-13 19:04:43 -04:00
ReinUsesLisp
30dbb951dd Fixup empty GLSL extension creation 2018-11-13 19:30:54 -03:00
FernandoS27
a6c435dcb7 Implement main conversion instructions 2018-11-12 14:37:54 -04:00
FernandoS27
aa2eaab480 Implemented ALL the logical instructions 2018-11-11 21:14:59 -04:00
ReinUsesLisp
bdf538bd64
Merge pull request #3 from FernandoS27/bit
Implemented the rest of the bitwise operations
2018-11-11 21:06:01 -03:00
FernandoS27
26a40708d7 Implemented a bunch of glsl functions 2018-11-11 20:03:29 -04:00
FernandoS27
aa3d1adbbd Implemented the rest of the bitwise operations 2018-11-11 18:51:08 -04:00
FernandoS27
c2646f3b4c Added more arithmetic instructions 2018-11-10 23:15:02 -04:00
ReinUsesLisp
8f17ad84ba Annotations return target and add OpUMod 2018-11-06 04:50:10 -03:00
ReinUsesLisp
c502cfd4b2 Add OpFDiv 2018-11-04 03:19:02 -03:00
ReinUsesLisp
27a0b4f17e Add OpFNegate 2018-11-04 03:11:25 -03:00
ReinUsesLisp
6742afd6dd Add support for GLSLstd450 and OpFAbs 2018-11-04 03:03:06 -03:00
ReinUsesLisp
44043bca56 Add OpCompositeConstruct 2018-11-04 02:38:13 -03:00
ReinUsesLisp
5830eca337 Remove Op* prefix for constants 2018-11-03 21:32:37 -03:00
ReinUsesLisp
1cd11815db Add OpMemberName 2018-11-03 21:29:24 -03:00
ReinUsesLisp
ad963b6520 Add OpCompositeExtract 2018-11-03 20:41:03 -03:00
ReinUsesLisp
65ccda50c7 Debug fixups 2018-11-03 03:40:20 -03:00
ReinUsesLisp
96e8290eef Add OpString 2018-11-03 01:14:29 -03:00
ReinUsesLisp
d4c95981b5 Add OpIAdd and OpBitwiseAnd 2018-11-03 00:52:44 -03:00
ReinUsesLisp
15a4d3c0d4 Add OpArithmetic 2018-11-02 23:49:41 -03:00
ReinUsesLisp
c29314ad14 Add OpShift arithmetic and logical operations 2018-11-02 23:44:09 -03:00
ReinUsesLisp
9c7f96a809 Add OpLogicalNot and OpBitcast 2018-11-02 23:24:10 -03:00
ReinUsesLisp
4f66fb18e9 Add version select and OpLogicalNot 2018-11-02 13:38:33 -03:00
ReinUsesLisp
4043020f45 Add OpFunctionCall 2018-11-01 22:16:17 -03:00
ReinUsesLisp
798f8a5866 Add OpReturnValue 2018-11-01 22:16:17 -03:00
ReinUsesLisp
91e0769db5 Fixup build issues 2018-11-01 05:13:30 -03:00
ReinUsesLisp
f3a63aa55f Use unique_ptr for instruction implementations 2018-11-01 00:02:45 -03:00
ReinUsesLisp
63ca1b5243 Rename Ref alias to Id 2018-10-31 22:20:49 -03:00
ReinUsesLisp
b8188f5ec4 Remove Op prefix for Name 2018-10-31 22:16:29 -03:00
ReinUsesLisp
a08aeec982 Add Op* prefix to instructions that have to be emited 2018-10-31 21:23:27 -03:00
ReinUsesLisp
80b0757ab6 Add OpStore 2018-10-31 05:05:06 -03:00
ReinUsesLisp
93c17d11f9 Add OpUndef 2018-10-31 04:26:35 -03:00
ReinUsesLisp
01c658b891 Add OpLoad 2018-10-31 04:16:26 -03:00
ReinUsesLisp
97825750a3 Add OpAccessChain 2018-10-31 03:37:36 -03:00
ReinUsesLisp
00fc8daf56 Use variant instead of creating an object for literals 2018-10-28 14:57:49 -03:00
ReinUsesLisp
8f8115d397 Add OpMemberDecorate 2018-10-28 05:38:10 -03:00
ReinUsesLisp
3f845b7c48 Fixup build errors 2018-10-28 04:59:15 -03:00
ReinUsesLisp
0863cd49c9 Use full names for files 2018-10-23 05:10:47 -03:00
ReinUsesLisp
8c1ab76ce5 Fix "for" incosistencies 2018-10-23 05:09:17 -03:00
ReinUsesLisp
6a2d1da742 Replace "auto const" with "auto" 2018-10-23 05:05:40 -03:00
ReinUsesLisp
f581df0935 Resolve leaks moving from Add to Sink 2018-10-23 05:02:18 -03:00
ReinUsesLisp
951ef21f17 Rename bad overload Add to Sink 2018-10-23 04:52:07 -03:00
ReinUsesLisp
4da63b4ed5 Ignore sirit.h symlink 2018-10-23 04:51:34 -03:00
ReinUsesLisp
1458bd2c1c Add OpDecorate 2018-10-23 04:45:56 -03:00
ReinUsesLisp
54cc7d06ce Add global variables 2018-10-20 02:52:55 -03:00
ReinUsesLisp
a3022e4969 Add OpVariable 2018-10-18 04:27:17 -03:00
ReinUsesLisp
c0aaf8989e Remove tailing "_" in constructor arguments 2018-10-17 03:44:48 -03:00
ReinUsesLisp
0485e1877c Use some C++17 features 2018-10-03 00:32:45 -03:00
ReinUsesLisp
45555c0e57 OpName returns its target 2018-08-31 04:55:01 -03:00
ReinUsesLisp
acea9030c5 Add OpName and debug symbols 2018-08-31 04:40:15 -03:00
ReinUsesLisp
a6946d3c8e Add OpBranchConditional 2018-08-31 04:17:32 -03:00
ReinUsesLisp
cdeeb9127c Add OpBranch 2018-08-31 04:17:32 -03:00
ReinUsesLisp
48ddaf4913 Add OpSelectionMerge 2018-08-31 04:17:32 -03:00
ReinUsesLisp
136dcf88a7 Add OpLoopMerge 2018-08-31 04:17:32 -03:00
ReinUsesLisp
2bafba1a17 Rename Assembly -> Assemble 2018-08-31 03:41:30 -03:00
ReinUsesLisp
a582641b99 Add OpConstantNull 2018-08-28 04:46:18 -03:00
ReinUsesLisp
42c456f24f Add OpConstantSampler 2018-08-28 04:41:42 -03:00
ReinUsesLisp
014c6ab586 Split literal files 2018-08-28 04:16:52 -03:00
ReinUsesLisp
edfc77bbbe Rename opcodes -> insts 2018-08-28 04:05:47 -03:00