-/*
- * Copyright (C) 2012, 2013, 2014
- * Dale Weiler
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is furnished to do
- * so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
#include <string.h>
#include <math.h>
sfloat_t s;
} sfloat_cast_t;
+/* Exception flags */
typedef enum {
SFLOAT_NOEXCEPT = 0,
SFLOAT_INVALID = 1,
SFLOAT_INEXACT = 32
} sfloat_exceptionflags_t;
+/* Rounding modes */
typedef enum {
SFLOAT_ROUND_NEAREST_EVEN,
SFLOAT_ROUND_DOWN,
SFLOAT_ROUND_TO_ZERO
} sfloat_roundingmode_t;
+/* Underflow tininess-detection mode */
typedef enum {
SFLOAT_TAFTER,
SFLOAT_TBEFORE
* this is seven bits to the left of its usual location. The shifted significand
* must be normalized or smaller than this. If it's not normalized then the exponent
* `exp_z' must be zero; in that case, the result returned is a subnormal number
- * and is must not require rounding. In the more usual case where the significand
+ * which must not require rounding. In the more usual case where the significand
* is normalized, the exponent must be one less than the *true* exponent.
*
* The handling of underflow and overflow is otherwise in alignment with IEC/IEEE.
/*
* There is two stages to constant folding in GMQCC: there is the parse
- * stage constant folding, where, witht he help of the AST, operator
+ * stage constant folding, where, with the help of the AST, operator
* usages can be constant folded. Then there is the constant folding
* in the IR for things like eliding if statements, can occur.
*
}
static GMQCC_INLINE ast_expression *fold_op_mul_vec(fold_t *fold, vec3_t vec, ast_value *sel, const char *set) {
- /*
- * vector-component constant folding works by matching the component sets
- * to eliminate expensive operations on whole-vectors (3 components at runtime).
- * to achive this effect in a clean manner this function generalizes the
- * values through the use of a set paramater, which is used as an indexing method
- * for creating the elided ast binary expression.
- *
- * Consider 'n 0 0' where y, and z need to be tested for 0, and x is
- * used as the value in a binary operation generating an INSTR_MUL instruction,
- * to acomplish the indexing of the correct component value we use set[0], set[1], set[2]
- * as x, y, z, where the values of those operations return 'x', 'y', 'z'. Because
- * of how ASCII works we can easily deliniate:
- * vec.z is the same as set[2]-'x' for when set[2] is 'z', 'z'-'x' results in a
- * literal value of 2, using this 2, we know that taking the address of vec->x (float)
- * and indxing it with this literal will yeild the immediate address of that component
- *
- * Of course more work needs to be done to generate the correct index for the ast_member_new
- * call, which is no problem: set[0]-'x' suffices that job.
- */
qcfloat_t x = (&vec.x)[set[0]-'x'];
qcfloat_t y = (&vec.x)[set[1]-'x'];
qcfloat_t z = (&vec.x)[set[2]-'x'];
-
if (!y && !z) {
ast_expression *out;
++opts_optimizationcount[OPTIM_VECTOR_COMPONENTS];
}
/*
- * Constant folding for compiler intrinsics, simaler approach to operator
- * folding, primarly: individual functions for each intrinsics to fold,
+ * Constant folding for compiler intrinsics, similar approach to operator
+ * folding, primarily: individual functions for each intrinsics to fold,
* and a generic selection function.
*/
static GMQCC_INLINE ast_expression *fold_intrin_isfinite(fold_t *fold, ast_value *a) {