28 #include <wx/spinctrl.h>
29 #include <wx/statline.h>
30 #include <wx/valgen.h>
31 #include <boost/format.hpp>
73 wxDialog(parent, -1, _T("Choose operation"), wxDefaultPosition),
77 createContents(
this,
true,
true);
78 operationList_ =
dynamic_cast<wxListBox*
>(
FindWindow(ID_LIST));
91 if (format_->name() ==
"riscv_r_type" ||
92 format_->name() ==
"riscv_i_type") {
95 if (format_->name() ==
"riscv_s_type" ||
96 format_->name() ==
"riscv_b_type") {
99 if (format_->name() ==
"riscv_u_type" ||
100 format_->name() ==
"riscv_j_type") {
108 if (format_->name() ==
"riscv_r_type" ||
109 format_->name() ==
"riscv_i_type" ||
110 format_->name() ==
"riscv_u_type" ||
111 format_->name() ==
"riscv_j_type") {
119 if (format_->name() ==
"riscv_r_type" ||
120 format_->name() ==
"riscv_i_type" ||
121 format_->name() ==
"riscv_s_type" ||
122 format_->name() ==
"riscv_b_type" ||
123 format_->name() ==
"riscv_u_type" ||
124 format_->name() ==
"riscv_j_type") {
132 std::map<std::string, int> ops;
133 if (format_->name() ==
"riscv_r_type") {
135 }
else if (format_->name() ==
"riscv_i_type") {
137 }
else if (format_->name() ==
"riscv_s_type") {
139 }
else if (format_->name() ==
"riscv_b_type") {
141 }
else if (format_->name() ==
"riscv_u_type") {
143 }
else if (format_->name() ==
"riscv_j_type") {
146 for (
const auto& op : ops) {
147 const std::string opName = op.first;
148 if (!opNameFilter_.empty() &&
149 opName.find(opNameFilter_) == std::string::npos) {
151 }
else if (format_->hasOperation(opName)) {
153 }
else if (op.first ==
"lui") {
154 opset.insert(opName);
158 if (format_->machine()->hasOperation(OAName)) {
159 opset.insert(opName);
172 operationList_->Clear();
174 std::set<TCEString> opset;
175 if (format_->name() ==
"riscv_r_type") {
177 format_->machine()->functionUnitNavigator();
178 for (
int i = 0; i < nav.
count(); i++) {
183 opName = opName.
lower();
184 if (!opNameFilter_.empty() &&
185 opName.find(opNameFilter_) == std::string::npos) {
187 }
else if (format_->hasOperation(opName)) {
197 opset.insert(opName);
202 opset = addRISCVBaseOperations(opset);
205 for (
const auto& opName : opset) {
226 if (operationList_->GetSelection() == wxNOT_FOUND) {
227 wxString message = _T(
"No operation selected.");
232 if (!format_->hasOperation(operation_)) {
233 format_->addOperation(operation_);
235 TransferDataFromWindow();
247 FindWindow(wxID_OK)->Enable(operationList_->GetSelection() != wxNOT_FOUND);
258 std::string pattern(event.GetString().mb_str());
259 std::string::iterator it;
260 it = std::remove_if(pattern.begin(), pattern.end(), [](
const char& c) {
263 pattern.erase(it, pattern.end());
264 for (
auto& c : pattern) c = toupper(c);
265 opNameFilter_ = pattern;
266 opNameFilter_ = opNameFilter_.lower();
278 wxBoxSizer *mainSizer =
new wxBoxSizer(wxVERTICAL);
280 wxBoxSizer *upperSizer =
new wxBoxSizer(wxHORIZONTAL);
283 wxBoxSizer *leftSizer =
new wxBoxSizer(wxVERTICAL);
285 wxListBox *opListBox =
new wxListBox(parent, ID_LIST, wxDefaultPosition,
286 wxSize(210, 150), 0, NULL, wxLB_SINGLE|wxLB_SORT);
287 leftSizer->Add(opListBox, 0, wxEXPAND|wxALL, 5);
290 wxBoxSizer *filterSizer =
new wxBoxSizer(wxHORIZONTAL);
292 wxStaticText *opNameFilterLabel =
new wxStaticText(parent,
293 ID_OP_FILTER_LABEL, wxT(
"Filter:"), wxDefaultPosition, wxDefaultSize,
296 wxTextCtrl *opNameFilter =
new wxTextCtrl(parent, ID_OP_FILTER, wxT(
""),
297 wxDefaultPosition, wxDefaultSize, 0);
298 filterSizer->Add(opNameFilterLabel, 0, 0);
299 filterSizer->Add(opNameFilter, 1, wxEXPAND);
300 leftSizer->Add(filterSizer, 0, wxEXPAND|wxALL, 5);
302 upperSizer->Add(leftSizer, 0, wxALL, 5);
304 mainSizer->Add(upperSizer, 1, wxEXPAND);
307 wxStaticLine *horisontalLine =
new wxStaticLine(parent, ID_LINE,
308 wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL);
309 mainSizer->Add(horisontalLine, 0, wxEXPAND|wxALL, 5);
312 wxBoxSizer *buttonsSizer =
new wxBoxSizer(wxHORIZONTAL);
314 wxButton *cancelButton =
new wxButton(parent, wxID_CANCEL, wxT(
"&Cancel"),
315 wxDefaultPosition, wxDefaultSize, 0);
316 buttonsSizer->Add(cancelButton, 0, wxALIGN_CENTER|wxALL, 5);
318 wxButton *okButton =
new wxButton(parent, wxID_OK, wxT(
"&OK"),
319 wxDefaultPosition, wxDefaultSize, 0);
320 buttonsSizer->Add(okButton, 0, wxALIGN_CENTER|wxALL, 5);
322 mainSizer->Add(buttonsSizer, 0, 0, 5);
325 parent->SetSizer(mainSizer);
327 mainSizer->SetSizeHints( parent );