Commit graph

169 commits

Author SHA1 Message Date
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
ReinUsesLisp
1869de6d75 tests: Fix build error 2019-03-14 04:33: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
ReinUsesLisp
151d9e816d
Merge pull request #10 from lioncash/order
op: Amend constructor initializer list order
2019-03-14 03:48:05 -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
ReinUsesLisp
2035d25bef
Merge pull request #7 from lioncash/override
src: Amend missing override specifiers
2019-03-14 03:40:04 -03:00
ReinUsesLisp
a8ac2068a6
Merge pull request #8 from lioncash/ref
sirit: Add missing reference argument specifier for OpLabel
2019-03-14 03:39:30 -03:00
Lioncash
59867b7907 sirit: Add missing reference argument specifier for OpLabel 2019-03-14 02:31:18 -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
3fa70013b8 Add missing instruction commentaries 2019-03-11 05:13:35 -03:00
ReinUsesLisp
4b1c1d1e38 Add ellipsis overloads for instructions ending in vectors 2019-03-11 04:38:09 -03:00
ReinUsesLisp
ee4ce61e62 Add name overload to OpLabel 2019-03-11 03:48:39 -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
664569a3b8 Avoid CMake SPIR-V module dependencies 2018-11-16 03:59:28 -03:00
ReinUsesLisp
fe67a427ff Fixup tests 2018-11-16 03:50:21 -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
ReinUsesLisp
7c15e838c6
Merge pull request #6 from FernandoS27/conversion
Implement main conversion instructions
2018-11-12 21:54:36 -03:00
FernandoS27
a6c435dcb7 Implement main conversion instructions 2018-11-12 14:37:54 -04:00
ReinUsesLisp
8747340c44
Merge pull request #4 from FernandoS27/logical
Implemented ALL the logical instructions
2018-11-11 22:20:37 -03: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
ReinUsesLisp
9a02f915a7
Merge pull request #2 from FernandoS27/glsl
Implemented a bunch of glsl functions
2018-11-11 21:05:14 -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
ReinUsesLisp
6790490271
Merge pull request #1 from FernandoS27/arith
Added more arithmetic instructions
2018-11-11 14:21:47 -03: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
587f1dc9f5
Update README.md 2018-11-05 03:44:29 -03:00
ReinUsesLisp
c502cfd4b2 Add OpFDiv 2018-11-04 03:19:02 -03:00