From: David Schleef Date: Mon, 30 Mar 2009 19:23:44 +0000 (-0700) Subject: Use printf attribute on orc_compiler_add_code X-Git-Tag: orc-0.4.0~73 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f9bdd87ced29825c1816ccd0a9b0545855611702;p=platform%2Fupstream%2Forc.git Use printf attribute on orc_compiler_add_code --- diff --git a/orc/opcodes.h b/orc/opcodes.h index 9f566ce..982daab 100644 --- a/orc/opcodes.h +++ b/orc/opcodes.h @@ -82,20 +82,20 @@ BINARY_SL(subssl, "ORC_CLAMP_SL((int64_t)%s - (int64_t)%s)") BINARY_UL(subusl, "ORC_CLAMP_UL((uint64_t)%s - (uint64_t)%s)") BINARY_SL(xorl, "%s ^ %s") -BINARY_BW(convsbw, "%s") -BINARY_BW(convubw, "(uint8_t)%s") -BINARY_WL(convswl, "%s") -BINARY_WL(convuwl, "(uint16_t)%s") -BINARY_WB(convwb, "%s") -BINARY_WB(convssswb, "ORC_CLAMP_SB(%s)") -BINARY_WB(convsuswb, "ORC_CLAMP_UB(%s)") -BINARY_WB(convusswb, "ORC_CLAMP_SB(%s)") -BINARY_WB(convuuswb, "ORC_CLAMP_UB(%s)") -BINARY_LW(convlw, "%s") -BINARY_LW(convssslw, "ORC_CLAMP_SW(%s)") -BINARY_LW(convsuslw, "ORC_CLAMP_UW(%s)") -BINARY_LW(convusslw, "ORC_CLAMP_SW(%s)") -BINARY_LW(convuuslw, "ORC_CLAMP_UW(%s)") +UNARY_BW(convsbw, "%s") +UNARY_BW(convubw, "(uint8_t)%s") +UNARY_WL(convswl, "%s") +UNARY_WL(convuwl, "(uint16_t)%s") +UNARY_WB(convwb, "%s") +UNARY_WB(convssswb, "ORC_CLAMP_SB(%s)") +UNARY_WB(convsuswb, "ORC_CLAMP_UB(%s)") +UNARY_WB(convusswb, "ORC_CLAMP_SB(%s)") +UNARY_WB(convuuswb, "ORC_CLAMP_UB(%s)") +UNARY_LW(convlw, "%s") +UNARY_LW(convssslw, "ORC_CLAMP_SW(%s)") +UNARY_LW(convsuslw, "ORC_CLAMP_UW(%s)") +UNARY_LW(convusslw, "ORC_CLAMP_SW(%s)") +UNARY_LW(convuuslw, "ORC_CLAMP_UW(%s)") BINARY_BW(mulsbw, "%s * %s") BINARY_BW(mulubw, "%s * %s") diff --git a/orc/orcprogram-c.c b/orc/orcprogram-c.c index 77a69ec..5c72e9a 100644 --- a/orc/orcprogram-c.c +++ b/orc/orcprogram-c.c @@ -170,6 +170,18 @@ c_get_type_name (int size) } +#define UNARY(name,op) \ +static void \ +c_rule_ ## name (OrcCompiler *p, void *user, OrcInstruction *insn) \ +{ \ + char dest[20], src1[20]; \ +\ + c_get_name (dest, p, insn->dest_args[0]); \ + c_get_name (src1, p, insn->src_args[0]); \ + \ + ORC_ASM_CODE(p," %s = " op ";\n", dest, src1); \ +} + #define BINARY(name,op) \ static void \ c_rule_ ## name (OrcCompiler *p, void *user, OrcInstruction *insn) \ @@ -189,16 +201,20 @@ c_rule_ ## name (OrcCompiler *p, void *user, OrcInstruction *insn) \ #define BINARY_UW(a,b) BINARY(a,b) #define BINARY_SL(a,b) BINARY(a,b) #define BINARY_UL(a,b) BINARY(a,b) -#define UNARY_SB(a,b) BINARY(a,b) -#define UNARY_UB(a,b) BINARY(a,b) -#define UNARY_SW(a,b) BINARY(a,b) -#define UNARY_UW(a,b) BINARY(a,b) -#define UNARY_SL(a,b) BINARY(a,b) -#define UNARY_UL(a,b) BINARY(a,b) +#define UNARY_SB(a,b) UNARY(a,b) +#define UNARY_UB(a,b) UNARY(a,b) +#define UNARY_SW(a,b) UNARY(a,b) +#define UNARY_UW(a,b) UNARY(a,b) +#define UNARY_SL(a,b) UNARY(a,b) +#define UNARY_UL(a,b) UNARY(a,b) #define BINARY_BW(a,b) BINARY(a,b) #define BINARY_WL(a,b) BINARY(a,b) #define BINARY_LW(a,b) BINARY(a,b) #define BINARY_WB(a,b) BINARY(a,b) +#define UNARY_BW(a,b) UNARY(a,b) +#define UNARY_WL(a,b) UNARY(a,b) +#define UNARY_LW(a,b) UNARY(a,b) +#define UNARY_WB(a,b) UNARY(a,b) #include "opcodes.h" @@ -218,6 +234,10 @@ c_rule_ ## name (OrcCompiler *p, void *user, OrcInstruction *insn) \ #undef BINARY_WL #undef BINARY_LW #undef BINARY_WB +#undef UNARY_BW +#undef UNARY_WL +#undef UNARY_LW +#undef UNARY_WB static OrcTarget c_target = { "c", @@ -253,6 +273,10 @@ orc_c_init (void) #define BINARY_WL(a,b) orc_rule_register (rule_set, #a , c_rule_ ## a, NULL); #define BINARY_LW(a,b) orc_rule_register (rule_set, #a , c_rule_ ## a, NULL); #define BINARY_WB(a,b) orc_rule_register (rule_set, #a , c_rule_ ## a, NULL); +#define UNARY_BW(a,b) orc_rule_register (rule_set, #a , c_rule_ ## a, NULL); +#define UNARY_WL(a,b) orc_rule_register (rule_set, #a , c_rule_ ## a, NULL); +#define UNARY_LW(a,b) orc_rule_register (rule_set, #a , c_rule_ ## a, NULL); +#define UNARY_WB(a,b) orc_rule_register (rule_set, #a , c_rule_ ## a, NULL); #include "opcodes.h" diff --git a/orc/orcprogram.h b/orc/orcprogram.h index 4b3883b..62b4c75 100644 --- a/orc/orcprogram.h +++ b/orc/orcprogram.h @@ -315,7 +315,8 @@ const char *orc_program_get_asm_code (OrcProgram *program); void orc_program_dump_asm (OrcProgram *program); const char *orc_target_get_asm_preamble (const char *target); -void orc_compiler_append_code (OrcCompiler *p, const char *fmt, ...); +void orc_compiler_append_code (OrcCompiler *p, const char *fmt, ...) + ORC_GNU_PRINTF(2,3); void orc_target_register (OrcTarget *target); OrcTarget *orc_target_get_by_name (const char *target_name); diff --git a/orc/orcutils.h b/orc/orcutils.h index 511773f..d921383 100644 --- a/orc/orcutils.h +++ b/orc/orcutils.h @@ -89,6 +89,12 @@ typedef unsigned int orc_bool; #define ORC_INTERNAL #endif +#if ORC_GNUC_PREREQ(3,3) /* guess */ +#define ORC_GNU_PRINTF(a,b) __attribute__((__format__ (__printf__, a, b))) +#else +#define ORC_GNU_PRINTF(a,b) +#endif + #ifdef __cplusplus #define ORC_BEGIN_DECLS extern "C" { #define ORC_END_DECLS }