SPRUIG6K January 2018 – March 2024
A print function is provided with C7000 Host Emulation that can be used on any TI vector type. This function prints out a formatted list of the contents of the vector. This function is specific to C7000 Host Emulation and is not supported by the C7000 compiler. As a result, references to this function must be omitted or protected by checks of the __C7X_HOSTEM__ preprocessor symbol in order to be compiled using the C7000 compiler. The following example shows how the print function can be used at different accessor levels of a vector.
/* Print function usage */
#ifndef __C7X_HOSTEM__
void print(int* ptr, int length)
{
// Loop over elements and print
}
#endif
int8 example = int8(int4(0), int4(1));
#ifdef __C7X_HOSTEM__
example.print(); // Prints: (0,0,0,0,1,1,1,1)
example.lo().print(); // Prints: (0,0,0,0)
example.hi().lo().print(); // Prints: (1,1)
example.even().print(); // Prints: (0,0,1,1)
example.even().hi().print(); // Prints: (1,1)
//example.s0().print(); // Illegal, member .s0 is a scalar value
__vload_dup(&example).print(); // Prints (0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1)
#else
// Target implementation
// NOTE: Output depends on print() implementation
print((int*)(&example), 8); // 0,0,0,0,1,1,1,1
// Error, can't take the address of a swizzle
//print((int*)(&example.hi()), 4);
// Option 1, preferred
int4 result_int4 = example.hi();
print((int*)(&result_int4), 4); // 1,1,1,1
// Option 2
print((((int *)&example)+2), 4); // 0,0,1,1
int16 result_int16 = __vload_dup(&example);
print((int*)&result_int16, 16); // 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1
#endif