@@ -64,11 +64,13 @@ CodeContainer::CodeContainer()
64
64
fComputeBlockInstructions(InstBuilder::genBlockInst()),
65
65
fPostComputeBlockInstructions(InstBuilder::genBlockInst()),
66
66
fComputeFunctions(InstBuilder::genBlockInst()),
67
- fUserInterfaceInstructions(InstBuilder::genBlockInst()),
68
- fInt32ControlNum(0 ),
69
- fRealControlNum(0 )
67
+ fUserInterfaceInstructions(InstBuilder::genBlockInst())
70
68
{
71
69
fCurLoop = new CodeLoop (0 , gGlobal ->getFreshID (" i" ));
70
+ // iControl/fControl are given as arguments, or kept as struct fields in -os3 mode.
71
+ Address::AccessType access = (gGlobal ->gOneSample == 3 ) ? Address::AccessType::kStruct : Address::AccessType::kFunArgs ;
72
+ fIntControl = new ArrayVar (" iControl" , access);
73
+ fRealControl = new ArrayVar (" fControl" , access);
72
74
}
73
75
74
76
CodeContainer::~CodeContainer ()
@@ -659,10 +661,7 @@ void CodeContainer::printMacros(ostream& fout, int n)
659
661
DeclareFunInst* CodeContainer::generateGetIO (const string& name, const string& obj, int io, bool ismethod,
660
662
FunTyped::FunAttribute funtype)
661
663
{
662
- Names args;
663
- if (!ismethod) {
664
- args.push_back (InstBuilder::genNamedTyped (obj, Typed::kObj_ptr ));
665
- }
664
+ Names args = genMethod (obj, ismethod);
666
665
BlockInst* block = InstBuilder::genBlockInst ();
667
666
block->pushBackInst (InstBuilder::genRetInst (InstBuilder::genInt32NumInst (io)));
668
667
@@ -683,10 +682,7 @@ DeclareFunInst* CodeContainer::generateGetOutputs(const string& name, const stri
683
682
684
683
DeclareFunInst* CodeContainer::generateAllocate (const string& name, const string& obj, bool ismethod, bool isvirtual)
685
684
{
686
- Names args;
687
- if (!ismethod) {
688
- args.push_back (InstBuilder::genNamedTyped (obj, Typed::kObj_ptr ));
689
- }
685
+ Names args = genMethod (obj, ismethod);
690
686
691
687
BlockInst* block = InstBuilder::genBlockInst ();
692
688
block->pushBackInst (fAllocateInstructions );
@@ -700,10 +696,7 @@ DeclareFunInst* CodeContainer::generateAllocate(const string& name, const string
700
696
701
697
DeclareFunInst* CodeContainer::generateDestroy (const string& name, const string& obj, bool ismethod, bool isvirtual)
702
698
{
703
- Names args;
704
- if (!ismethod) {
705
- args.push_back (InstBuilder::genNamedTyped (obj, Typed::kObj_ptr ));
706
- }
699
+ Names args = genMethod (obj, ismethod);
707
700
708
701
BlockInst* block = InstBuilder::genBlockInst ();
709
702
block->pushBackInst (fDestroyInstructions );
@@ -718,10 +711,7 @@ DeclareFunInst* CodeContainer::generateDestroy(const string& name, const string&
718
711
DeclareFunInst* CodeContainer::generateGetIORate (const string& name, const string& obj, vector<int >& io, bool ismethod,
719
712
bool isvirtual)
720
713
{
721
- Names args;
722
- if (!ismethod) {
723
- args.push_back (InstBuilder::genNamedTyped (obj, Typed::kObj_ptr ));
724
- }
714
+ Names args = genMethod (obj, ismethod);
725
715
args.push_back (InstBuilder::genNamedTyped (" channel" , Typed::kInt32 ));
726
716
727
717
BlockInst* block = InstBuilder::genBlockInst ();
@@ -757,11 +747,8 @@ DeclareFunInst* CodeContainer::generateGetIORate(const string& name, const strin
757
747
DeclareFunInst* CodeContainer::generateInstanceClear (const string& name, const string& obj, bool ismethod,
758
748
bool isvirtual)
759
749
{
760
- Names args;
761
- if (!ismethod) {
762
- args.push_back (InstBuilder::genNamedTyped (obj, Typed::kObj_ptr ));
763
- }
764
-
750
+ Names args = genMethod (obj, ismethod);
751
+
765
752
BlockInst* block = InstBuilder::genBlockInst ();
766
753
block->pushBackInst (fClearInstructions );
767
754
@@ -775,10 +762,7 @@ DeclareFunInst* CodeContainer::generateInstanceClear(const string& name, const s
775
762
DeclareFunInst* CodeContainer::generateInstanceConstants (const string& name, const string& obj, bool ismethod,
776
763
bool isvirtual)
777
764
{
778
- Names args;
779
- if (!ismethod) {
780
- args.push_back (InstBuilder::genNamedTyped (obj, Typed::kObj_ptr ));
781
- }
765
+ Names args = genMethod (obj, ismethod);
782
766
args.push_back (InstBuilder::genNamedTyped (" sample_rate" , Typed::kInt32 ));
783
767
784
768
BlockInst* block = InstBuilder::genBlockInst ();
@@ -818,10 +802,7 @@ DeclareFunInst* CodeContainer::generateStaticInitFun(const string& name, bool is
818
802
DeclareFunInst* CodeContainer::generateInstanceInitFun (const string& name, const string& obj, bool ismethod,
819
803
bool isvirtual)
820
804
{
821
- Names args;
822
- if (!ismethod) {
823
- args.push_back (InstBuilder::genNamedTyped (obj, Typed::kObj_ptr ));
824
- }
805
+ Names args = genMethod (obj, ismethod);
825
806
args.push_back (InstBuilder::genNamedTyped (" sample_rate" , Typed::kInt32 ));
826
807
827
808
BlockInst* init_block = InstBuilder::genBlockInst ();
@@ -839,10 +820,7 @@ DeclareFunInst* CodeContainer::generateInstanceInitFun(const string& name, const
839
820
840
821
DeclareFunInst* CodeContainer::generateFillFun (const string& name, const string& obj, bool ismethod, bool isvirtual)
841
822
{
842
- Names args;
843
- if (!ismethod) {
844
- args.push_back (InstBuilder::genNamedTyped (obj, Typed::kObj_ptr ));
845
- }
823
+ Names args = genMethod (obj, ismethod);
846
824
args.push_back (InstBuilder::genNamedTyped (" count" , Typed::kInt32 ));
847
825
if (fSubContainerType == kInt ) {
848
826
args.push_back (InstBuilder::genNamedTyped (fTableName , Typed::kInt32_ptr ));
@@ -868,27 +846,18 @@ DeclareFunInst* CodeContainer::generateFillFun(const string& name, const string&
868
846
869
847
DeclareFunInst* CodeContainer::generateInit (const string& name, const string& obj, bool ismethod, bool isvirtual)
870
848
{
871
- Names args;
872
- if (!ismethod) {
873
- args.push_back (InstBuilder::genNamedTyped (obj, Typed::kObj_ptr ));
874
- }
849
+ Names args = genMethod (obj, ismethod);
875
850
args.push_back (InstBuilder::genNamedTyped (" sample_rate" , Typed::kInt32 ));
876
851
877
852
BlockInst* block = InstBuilder::genBlockInst ();
878
853
{
879
- Values args1;
880
- if (!ismethod) {
881
- args1.push_back (InstBuilder::genLoadFunArgsVar (obj));
882
- }
854
+ Values args1 = genObjArg (obj, ismethod);
883
855
args1.push_back (InstBuilder::genLoadFunArgsVar (" sample_rate" ));
884
856
block->pushBackInst (InstBuilder::genVoidFunCallInst (" classInit" , args1));
885
857
}
886
858
887
859
{
888
- Values args1;
889
- if (!ismethod) {
890
- args1.push_back (InstBuilder::genLoadFunArgsVar (obj));
891
- }
860
+ Values args1 = genObjArg (obj, ismethod);
892
861
args1.push_back (InstBuilder::genLoadFunArgsVar (" sample_rate" ));
893
862
block->pushBackInst (InstBuilder::genVoidFunCallInst (" instanceInit" , args1));
894
863
}
@@ -900,35 +869,23 @@ DeclareFunInst* CodeContainer::generateInit(const string& name, const string& ob
900
869
DeclareFunInst* CodeContainer::generateInstanceInit (const string& name, const string& obj, bool ismethod,
901
870
bool isvirtual)
902
871
{
903
- Names args;
904
- if (!ismethod) {
905
- args.push_back (InstBuilder::genNamedTyped (obj, Typed::kObj_ptr ));
906
- }
872
+ Names args = genMethod (obj, ismethod);
907
873
args.push_back (InstBuilder::genNamedTyped (" sample_rate" , Typed::kInt32 ));
908
874
909
875
BlockInst* block = InstBuilder::genBlockInst ();
910
876
{
911
- Values args1;
912
- if (!ismethod) {
913
- args1.push_back (InstBuilder::genLoadFunArgsVar (obj));
914
- }
877
+ Values args1 = genObjArg (obj, ismethod);
915
878
args1.push_back (InstBuilder::genLoadFunArgsVar (" sample_rate" ));
916
879
block->pushBackInst (InstBuilder::genVoidFunCallInst (" instanceConstants" , args1));
917
880
}
918
881
919
882
{
920
- Values args1;
921
- if (!ismethod) {
922
- args1.push_back (InstBuilder::genLoadFunArgsVar (obj));
923
- }
883
+ Values args1 = genObjArg (obj, ismethod);
924
884
block->pushBackInst (InstBuilder::genVoidFunCallInst (" instanceResetUserInterface" , args1));
925
885
}
926
886
927
887
{
928
- Values args1;
929
- if (!ismethod) {
930
- args1.push_back (InstBuilder::genLoadFunArgsVar (obj));
931
- }
888
+ Values args1 = genObjArg (obj, ismethod);
932
889
block->pushBackInst (InstBuilder::genVoidFunCallInst (" instanceClear" , args1));
933
890
}
934
891
@@ -939,10 +896,7 @@ DeclareFunInst* CodeContainer::generateInstanceInit(const string& name, const st
939
896
DeclareFunInst* CodeContainer::generateGetSampleRate (const string& name, const string& obj, bool ismethod,
940
897
bool isvirtual)
941
898
{
942
- Names args;
943
- if (!ismethod) {
944
- args.push_back (InstBuilder::genNamedTyped (obj, Typed::kObj_ptr ));
945
- }
899
+ Names args = genMethod (obj, ismethod);
946
900
947
901
BlockInst* block = InstBuilder::genBlockInst ();
948
902
block->pushBackInst (InstBuilder::genRetInst (InstBuilder::genLoadStructVar (" fSampleRate" )));
@@ -955,10 +909,7 @@ DeclareFunInst* CodeContainer::generateGetSampleRate(const string& name, const s
955
909
956
910
DeclareFunInst* CodeContainer::generateComputeFun (const string& name, const string& obj, bool ismethod, bool isvirtual)
957
911
{
958
- Names args;
959
- if (!ismethod) {
960
- args.push_back (InstBuilder::genNamedTyped (obj, Typed::kObj_ptr ));
961
- }
912
+ Names args = genMethod (obj, ismethod);
962
913
args.push_back (InstBuilder::genNamedTyped (" count" , Typed::kInt32 ));
963
914
args.push_back (InstBuilder::genNamedTyped (" inputs" , Typed::kFloatMacro_ptr_ptr ));
964
915
args.push_back (InstBuilder::genNamedTyped (" outputs" , Typed::kFloatMacro_ptr_ptr ));
0 commit comments