This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] 编译器/BEAGLEBK:BBB PRU-ICSS 编译器:GCC "标注为值"扩展?

Guru**** 2578945 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/942640/compiler-beaglebk-bbb-pru-icss-compiler-gcc-labels-as-value-extension

器件型号:BEAGLEBK

工具/软件:TI C/C++编译器

您好!

我正在优化 BeagleBoneBlack 上的 PRU 状态机。

执行状态代码和更改状态的经典方法是一个 big switch()语句,如下所示:


#define State_stop 0
#define State_A 1.

#define State_B 2.
#define State_C 3.
(笑声)

int statemachine (int state){

switch (state){
案例 State_A:
  do 什么东西();
  if (some 条件)
    返回 State_B;
  其他
   返回 State_stop;
   
用例 State_B:
 (笑声)
 。
 }

}    

main(){

 (笑声)
  STATE = State_A;
  while (state = statmachine(statstate));

  (笑声)


 

我看到 PRU-ICSS clpru 编译器(此处为2.3.1)编译了"switch()…… 案例"作为测试列表、如此伪代码

如果(状态= 1)则如此
(笑声)
否则、如果(状态= 2)则为

否则、如果(状态= 3)则为
(笑声)

由于我在这里有一些情况、这个测试链占用了 PRU 执行时间的一部分。

 

如果使用一个"计算得到的 gotos"数组、可以生成更快的代码。 GCC 支持将其作为"labels as values"扩展名、如以下堆栈溢出示例中所示:

<fastcode>
int main(){
    int value  = 2;
    const void *labels[] = {&&val_0, &&val_1, &&val_2};
    goto *labels[value];
    val_0:
        printf("The value is 0\n");
        goto end;
    val_1:
        printf("The value is 1\n");
        goto end;
    val_2:
        printf("The value is 2\n");
        goto end;
    end:
    return(0);
}
</fastcode>
 

"Labels as values" is a strange feature of course, its justification seems limited to writing zero-overhead command processors.

Sadly, the "Labels as values" extension seems not supported in clpru 2.3.1 ... clpru complains like

Invoking: PRU Compiler
..... /ti-cgt-pru_2.3.1//bin/clpru --include_path= ....
"pru1_statemachine_data_slave.c", line 51: error #1489: GCC && operator not
          supported
      const void* labelarray[] = &&lab1, &&lab2, &&lab3} ;
                          
Any chance to get "labels as values" implemented in clpru?

best regards,
Joerg

 

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    [引用 user="Joierg Hoppe">是否有机会在 clpru 中实现"标签作为值"?
    [/报价]

    遗憾的是、没有计划将该功能添加到 PRU 编译器中。

    谢谢、此致、

    乔治