summaryrefslogtreecommitdiff
path: root/src/mem/slicc/ast
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/slicc/ast')
-rw-r--r--src/mem/slicc/ast/ASTs.hh1
-rw-r--r--src/mem/slicc/ast/EnqueueStatementAST.cc2
-rw-r--r--src/mem/slicc/ast/MachineAST.cc6
-rw-r--r--src/mem/slicc/ast/MachineAST.hh5
-rw-r--r--src/mem/slicc/ast/MethodCallExprAST.cc26
-rw-r--r--src/mem/slicc/ast/NewExprAST.cc9
-rw-r--r--src/mem/slicc/ast/NewExprAST.hh20
-rw-r--r--src/mem/slicc/ast/ObjDeclAST.cc29
8 files changed, 68 insertions, 30 deletions
diff --git a/src/mem/slicc/ast/ASTs.hh b/src/mem/slicc/ast/ASTs.hh
index d0ed5698f..3363fbb09 100644
--- a/src/mem/slicc/ast/ASTs.hh
+++ b/src/mem/slicc/ast/ASTs.hh
@@ -72,6 +72,7 @@
#include "mem/slicc/ast/InfixOperatorExprAST.hh"
#include "mem/slicc/ast/FuncCallExprAST.hh"
#include "mem/slicc/ast/MethodCallExprAST.hh"
+#include "mem/slicc/ast/NewExprAST.hh"
#include "mem/slicc/ast/ChipComponentAccessAST.hh"
diff --git a/src/mem/slicc/ast/EnqueueStatementAST.cc b/src/mem/slicc/ast/EnqueueStatementAST.cc
index e323e67ac..744dfe1eb 100644
--- a/src/mem/slicc/ast/EnqueueStatementAST.cc
+++ b/src/mem/slicc/ast/EnqueueStatementAST.cc
@@ -77,7 +77,7 @@ void EnqueueStatementAST::generate(string& code, Type* return_type_ptr) const
code += ".enqueue(out_msg";
if (getPairs().exist("latency")) {
- code += ", " + getPairs().lookup("latency");
+ code += ", RubyConfig::get" + getPairs().lookup("latency") + "()";
}
code += ");\n";
diff --git a/src/mem/slicc/ast/MachineAST.cc b/src/mem/slicc/ast/MachineAST.cc
index 8c2f647be..2096db591 100644
--- a/src/mem/slicc/ast/MachineAST.cc
+++ b/src/mem/slicc/ast/MachineAST.cc
@@ -41,13 +41,17 @@
MachineAST::MachineAST(string* ident_ptr,
PairListAST* pairs_ptr,
+ Vector<TypeFieldAST*>* config_params_ptr,
+ std::vector<std::string*>* latency_vector,
DeclListAST* decl_list_ptr)
: DeclAST(pairs_ptr)
{
m_ident_ptr = ident_ptr;
m_pairs_ptr = pairs_ptr;
+ m_config_params_ptr = config_params_ptr;
m_decl_list_ptr = decl_list_ptr;
+ m_latency_vector = latency_vector;
}
MachineAST::~MachineAST()
@@ -65,7 +69,7 @@ void MachineAST::generate()
g_sym_table.pushFrame();
// Create a new machine
- machine_ptr = new StateMachine(*m_ident_ptr, getLocation(), getPairs());
+ machine_ptr = new StateMachine(*m_ident_ptr, getLocation(), getPairs(), m_latency_vector);
g_sym_table.newCurrentMachine(machine_ptr);
// Generate code for all the internal decls
diff --git a/src/mem/slicc/ast/MachineAST.hh b/src/mem/slicc/ast/MachineAST.hh
index 037803db5..8f83e4cfe 100644
--- a/src/mem/slicc/ast/MachineAST.hh
+++ b/src/mem/slicc/ast/MachineAST.hh
@@ -42,6 +42,7 @@
#include "mem/slicc/slicc_global.hh"
#include "mem/slicc/ast/DeclAST.hh"
#include "mem/slicc/ast/DeclListAST.hh"
+#include "mem/slicc/ast/TypeFieldAST.hh"
#include "mem/slicc/symbols/StateMachine.hh"
class MachineAST : public DeclAST {
@@ -49,6 +50,8 @@ public:
// Constructors
MachineAST(string* ident_ptr,
PairListAST* pairs_ptr,
+ Vector<TypeFieldAST*>* config_params_ptr,
+ std::vector<std::string*>* latency_vector,
DeclListAST* decl_list_ptr);
// Destructor
@@ -66,8 +69,10 @@ private:
MachineAST& operator=(const MachineAST& obj);
// Data Members (m_ prefix)
+ std::vector<std::string*>* m_latency_vector;
string* m_ident_ptr;
DeclListAST* m_decl_list_ptr;
+ Vector<TypeFieldAST*>* m_config_params_ptr;
PairListAST* m_pairs_ptr;
};
diff --git a/src/mem/slicc/ast/MethodCallExprAST.cc b/src/mem/slicc/ast/MethodCallExprAST.cc
index 0e2fed769..1bfe312ff 100644
--- a/src/mem/slicc/ast/MethodCallExprAST.cc
+++ b/src/mem/slicc/ast/MethodCallExprAST.cc
@@ -76,25 +76,38 @@ Type* MethodCallExprAST::generate(string& code) const
{
Type* obj_type_ptr = NULL;
+ string methodId;
+ Vector <Type*> paramTypes;
+
+ int actual_size = m_expr_vec_ptr->size();
+ for(int i=0; i<actual_size; i++) {
+ string tmp;
+ Type* actual_type_ptr = (*m_expr_vec_ptr)[i]->generate(tmp);
+ paramTypes.insertAtBottom(actual_type_ptr);
+ }
+
if(m_obj_expr_ptr) {
// member method call
+ string tmp;
+ obj_type_ptr = m_obj_expr_ptr->generate(tmp);
+ methodId = obj_type_ptr->methodId(*m_proc_name_ptr, paramTypes);
+ if (obj_type_ptr->methodReturnType(methodId)->isInterface())
+ code += "static_cast<" + obj_type_ptr->methodReturnType(methodId)->cIdent() + "&>";
code += "((";
- obj_type_ptr = m_obj_expr_ptr->generate(code);
-
+ code += tmp;
code += ").";
} else if (m_type_ptr) {
// class method call
code += "(" + m_type_ptr->toString() + "::";
obj_type_ptr = m_type_ptr->lookupType();
+ methodId = obj_type_ptr->methodId(*m_proc_name_ptr, paramTypes);
} else {
// impossible
assert(0);
}
- Vector <Type*> paramTypes;
-
// generate code
- int actual_size = m_expr_vec_ptr->size();
+ actual_size = m_expr_vec_ptr->size();
code += (*m_proc_name_ptr) + "(";
for(int i=0; i<actual_size; i++) {
if (i != 0) {
@@ -102,12 +115,9 @@ Type* MethodCallExprAST::generate(string& code) const
}
// Check the types of the parameter
Type* actual_type_ptr = (*m_expr_vec_ptr)[i]->generate(code);
- paramTypes.insertAtBottom(actual_type_ptr);
}
code += "))";
- string methodId = obj_type_ptr->methodId(*m_proc_name_ptr, paramTypes);
-
// Verify that this is a method of the object
if (!obj_type_ptr->methodExist(methodId)) {
error("Invalid method call: Type '" + obj_type_ptr->toString() + "' does not have a method '" + methodId + "'");
diff --git a/src/mem/slicc/ast/NewExprAST.cc b/src/mem/slicc/ast/NewExprAST.cc
new file mode 100644
index 000000000..95e57192f
--- /dev/null
+++ b/src/mem/slicc/ast/NewExprAST.cc
@@ -0,0 +1,9 @@
+
+#include "mem/slicc/ast/NewExprAST.hh"
+
+Type* NewExprAST::generate(string & code) const
+{
+ Type* type = m_type_ptr->lookupType();
+ code += "new " + type->cIdent();
+ return type;
+}
diff --git a/src/mem/slicc/ast/NewExprAST.hh b/src/mem/slicc/ast/NewExprAST.hh
new file mode 100644
index 000000000..375f130d6
--- /dev/null
+++ b/src/mem/slicc/ast/NewExprAST.hh
@@ -0,0 +1,20 @@
+#ifndef NEWEXPRAST_H
+#define NEWEXPRAST_H
+
+#include "mem/slicc/ast/ExprAST.hh"
+#include "mem/slicc/ast/TypeAST.hh"
+#include "mem/slicc/symbols/Type.hh"
+
+class NewExprAST : public ExprAST
+{
+public:
+ NewExprAST(TypeAST* type_ptr) : ExprAST() { m_type_ptr = type_ptr; }
+ Type* generate(string & code) const;
+ void print(ostream & out) const { out << "[NewExprAST: " << *m_type_ptr << "]"; }
+ string getName() const { return m_type_ptr->toString(); }
+
+private:
+ TypeAST* m_type_ptr;
+};
+
+#endif
diff --git a/src/mem/slicc/ast/ObjDeclAST.cc b/src/mem/slicc/ast/ObjDeclAST.cc
index f9349f9de..3569395db 100644
--- a/src/mem/slicc/ast/ObjDeclAST.cc
+++ b/src/mem/slicc/ast/ObjDeclAST.cc
@@ -108,32 +108,21 @@ void ObjDeclAST::generate()
c_code = "m_version";
} else if (*m_ident_ptr == "machineID") {
c_code = "m_machineID";
- } else if (*m_ident_ptr == "sequencer") {
- c_code = "*(dynamic_cast<"+m_type_ptr->toString()+"*>(m_chip_ptr->getSequencer(m_version)))";
- machineComponentSym = true;
- } /*else if (*m_ident_ptr == "xfdr_record_mgr") {
- c_code = "*(dynamic_cast<"+m_type_ptr->toString()+"*>(m_chip_ptr->getXfdrManager(m_version)))";
- machineComponentSym = true;
- } */else if (// getPairs().exist("network") || (m_type_ptr->lookupType()->existPair("cache"))
-// || (m_type_ptr->lookupType()->existPair("tbe")) ||
-// (m_type_ptr->lookupType()->existPair("newtbe")) ||
-// (m_type_ptr->lookupType()->existPair("timer")) ||
-// (m_type_ptr->lookupType()->existPair("dir")) ||
-// (m_type_ptr->lookupType()->existPair("persistent")) ||
-// (m_type_ptr->lookupType()->existPair("filter")) ||
-// (getPairs().exist("trigger_queue"))
- getPairs().exist("no_vector")) {
- c_code = "(*(m_chip_ptr->m_" + machine + *m_ident_ptr + "_ptr))";
- machineComponentSym = true;
} else {
- c_code = "(*(m_chip_ptr->m_" + machine + *m_ident_ptr + "_vec[m_version]))";
- machineComponentSym = true;
+ c_code = "(*m_" + machine + *m_ident_ptr + "_ptr)";
+ // c_code = "(*(m_chip_ptr->m_" + machine + *m_ident_ptr + "_ptr))";
+ // machineComponentSym = true;
}
Var* v = new Var(*m_ident_ptr, getLocation(), type_ptr, c_code,
getPairs(), g_sym_table.getStateMachine());
- g_sym_table.newSym(v);
+ StateMachine* machine_ptr = g_sym_table.getStateMachine();
+ if (machine_ptr != NULL) {
+ machine_ptr->addObj(v);
+ }// else {
+ g_sym_table.newSym(v);
+ //}
// used to cheat-- that is, access components in other machines
if (machineComponentSym) {