[LLVMdev] Anyone is building a DSP-C frontend?
tzuchien.chiu at gmail.com
Tue Aug 30 18:06:54 PDT 2005
fixed-point number could be stored in LLVM first class integer types.
i cannot see the problem now. but to be type-safe, there should be a
first class 'fixed'.
some llvm extensions required to mapping dsp-c lanaguages could be
implemented as qualifiers.
1. _sat qualifier
Saturate the result within [0.0, +1.0> or [-1.0,+1.0> (unsigned/singed).
sat signed fixed a;
sat signed fixed b;
sat signed fixed c;
a = -0.75r; // 'r' is fixed-point number postfix
b = -0.75r;
c = a + b; /* c = -1.0r !!! */
this qualifier can be implemented just like the 'const' qualifier.
btw, in some implementation, the saturation is explicitly specifiedby
the arithmetic operation, not the variable itself. for example:
/* add the operands, saturate the result before it's assigned to c */
c = add_sat(-0.75, -0.75);
2. memory space qualifier
a typical program will have its global variables and constant in
different data segments. a segment is just a block with continuous
memory. there is no difference where the segment is. however, it's
different in the embedded system. usually constants are preferred to
be put in the ROM, while the global vars in SRAM. however, sometimes
the dsp programmer wants to explicitly specify where the data is. for
example, to put constant in RAM. for some strange reasons like cost
and access time.
int __rom x = 0; // const in ROM
int __ram y = 1; // const in RAM
3D Graphics Hardware Architect
More information about the llvm-dev